Detailed interactive front and rear end (recommended collection)

Here Insert Picture Description

1. The front and rear ends of cognitive

  • I believe many people have a confused mind: I ⼀ front-end, back-end learning why?
    Here Insert Picture Description

  • So in the end what is the front? What is the back end? What is a database?

Here Insert Picture Description

1.1 The basic organizational structure

  • We are ⼀ a front-end development engineer ⼯

  • There ⼀ a ⼯ known as back-end development engineer ⼯

  • We ⼀ a website for the organization is basically done by the screen for the next step

    ⽤户 => 前端 => 后端 => 数据库
    
  • Throughout the process:

     ⽤户向前端⼈员要⼀个⽹⻚
     前端⼈员准备⼀个⽹⻚给⽤户,但是⽹⻚中的数据是找后端⼈员要的
     后端⼈员接受到前端⼈员要数据以后,去数据库⾥⾯找到对应的数据,给
     到前端⼈员
     前端⼈员拿到数据以后渲染在⻚⾯上
     最后把这个⻚⾯给到⽤户看
    
  • ⽐ such as: we visit a news website for ⼀

     ⽤户输⼊⽹址
     前端⼈员就要把对应的⻚⾯给到⽤户,在⻚⾯打开的过程中,向后端⼈员索要新闻信息
     后端⼈员接收到前端⼈员索要新闻信息以后,就去数据库中找到对应的新闻信息数据给前端⼈员
     前端⼈员接收到后端⼈员给的新闻信息以后,使⽤我们的办法把新闻信息数据渲染在⻚⾯上
     ⻚⾯就打开了,⽤户就可以看到⼀个新闻⽹站了
    
  • ⽐ such as: Using a website for user login ⼀

     当⽤户书写完表单内容以后,点击提交按钮的时候
     前端⼈员拿到⽤户填写的内容,把数据整合好传送给后端⼈员
     后端⼈员接收到数据以后,去数据库中进⾏⽐对,看看有没有对应的数据
     然后告诉前端⼈员,你给我的⽤户名和密码是否正确
     前端把信息反馈给客户看到
     如果正确那么就是跳转⻚⾯
     如果不正确提示⽤户名或者密码有问题,重新输入或者...
    

2. Understanding Server

2.1 What is a server? Here Insert Picture DescriptionIn fact, White said, the server is ⼀ a computer , when he ran up ⼀ these procedures when it becomes ⼀ servers, but will run ⼀ some special program, It takes some special circumstances, the computer does not he ⼀ ⽽ been kind
words, we Your Own PC, running ⼀ some special procedures, they can also be used as one hour for any type of server to use, be able to calculate but care has been taken / storage can care has been taken / dump can care has been taken not professional computer server has been badly ⽽.

The role Server 2.2
Here Insert Picture Description
2.3 server is how accessible

  • ⽐ as www.baidu.com our frequently accessed

  • The ⾥ ⾯ contains a lot of content, this is just a ⼀ omitted after we see

  • Browser help us ⼀ omitted some content

  • All addresses should be https://www.baidu.com:443

  • Found two more East ⻄ https: // and: 443

  • In fact, ⼀ simple url address is composed of three parts

     传输协议
     域名
     端⼝号
    

Transfer Protocol

  • We often ⻅ transfer protocol is http and https

  • They are restricting shutter mode and regular exchange of data transfer between users and servers Use

  • Also the front-end and back-end personnel on a regular interactions

  • rule

    建⽴连接通道
    相互通信
    关闭连接通道
    
  • Http ⼀ is just kind often ⻅ agreement, not very safe

  • https is ⼀ scramble transmission protocols

domain name

  • Before we said, a server that is ⼀ in Open networks that ⼀ head ⼀ a computer
  • Previously, no concept of domain names are zoomed home Using the IP address to access
  • Open networks is that ⼀ head of the computer's IP stack are ⼀ numbers, they do not ⽅ memory
  • And then there is a ⼀Web ⽹He put every ⼀ IP addresses matching the ⼀ alphanumeric name of the file, then ⽅ Using memory households
  • So, the domain name to represent the IP address of the head of the Open networks that ⼀ computer
  • In fact, what we want to access a server which ⼀

No end-connector

  • Face home server computer is a lot of folders in
  • Different folder ⾥ ⾯ different content stores
  • There may be a folder, stored ⾥ ⾯ is therefore especially ⻚
  • B may have a folder, ⾥ ⾯ such data storage is ⼀
  • So, you find the server computer is not ⾏ light, I have come to the right folders can
  • Regarded zoomed home folder to store the code on the number of 0 to 255, a total of 256
  • Each folder corresponding ⾥ ⾯ there ⼩ folder 0 to 255, a total of 256
  • So there is a total of 256 * 256 folders, that is, from 0 to 65535
  • So we have a number of end-connector 65536, corresponding to 0 to 65535
  • Home zoomed regarded as number-connector end 80 ⼀ a website for the default port number-connector
  • http is the default protocol end-connector No. 80
  • The default is https protocol end-connector No. 443

Baidu

  • So now we come back to see the complete url address of Baidu

  • https://www.baidu.com:443

      以⼀种加密传输协议来通讯
      访问的是⽹络上 IP 的值为 119.75.217.109 的那个电脑 
      访问的是第 443 号⽂件夹 
    
  • This folder ⾥ ⾯ stores ⼀ a Baidu's ⻚ ⾯

  • We can see that the ⻚ ⾯

3. PHP

  • PHP: ⼀ ⻔ your language and backend

  • Why learn your language and it ⼀ backend?

       ⽬前市场上的需求,要求前端⼈员掌握⼀个后端语⾔ 
       ⽅便和后端开发⼈员进⾏交互
    

3.1 PHP basic syntax

  • We ⼀ given to know, php your language and is for another time, and no longer our html / javascript up
  • So you must have your language and other home your language and the rules of the Face
  • When we write javascript is ⼀ a .js files
  • When we write html is ⼀ a .html files
  • php code necessary to write in the file ⼀ a .php suffix

3.2 php files written

  • All php code to be written in php of a range ⼀
  • Requirements to <? Php beginning
  • Requirements to?> Ending
  • After each ⼀ statement ⾯ should have;
<?php
# php 的代码写在这⾥
?>

Define the variable

  • Do not give us the var keyword to define variables in php
  • Direct Use $ variables to determine ⼀
<?php
# 下⾯就是⼀个定义了⼀个变量,并且赋值为 100
# 变量名就是 $num
 $num = 100;
 $boo = true;
# 下⾯是⼀个字符串
 $str = "你好 php";
?>

Conditional statements

Substantially ⼀ induced in php Using conditional statements and manipulation js

<?php
$boo = true;
if ($boo) {
echo '你好,欢迎观临!';
} else {
echo '您还没有登陆';
} 
?>

Loop
in php loop and actuator js substantially ⼀

<?php
$num = 5;
for ($i = 0; $i < $num; $i++) {
echo 'hello php'; }
?>

String concatenation
in php, string concatenation is no longer Use + ⾏ into the splice, it is ⽽ Use intake splicing ⾏

$str = 'hello ';
$str2 = 'world';
$str3 = $str . $str2;
echo $str3;
# 得到的就是 hello world

Array
not particularly ⼀ samples in php array and the js

<?php
# 创建⼀个数组
 $arr = array(1, 2, 3);
 print_r($arr);
# Array ( [0] => 1 [1] => 2 [2] => 3 )
# 这个就类似于我们 js 中的数组,按照索引来的
# 创建⼀个关联数组
 $arr2 = array('name' => 'Jack', 'age' => 18, 'gender' => '男')
 print_r($arr2)
# Array ( [name] => Jack [age] => 18 [gender] => 男 )
# 这个就类似于我们 js 中的 对象,键值对的形式
?>

4. MySQL database

Here Insert Picture Description

  • mysql and php is the name of ⽐ cooperation ⼀ database of good database

  • Before we said ⼀ question,Front-end to back-end data to ask for, is to go to the back-end database query data, return to the front

     MySQL 是最流⾏的关系型数据库管理系统(⾮关系型数据库简略介绍)
     关系数据库管理系统(Relational Database Management System)的特点
     数据以表格的形式出现
     每⾏为各种记录名称
     许多的⾏和列组成⼀张表单
     若⼲的表单组成database
     主键:主键是唯⼀的。⼀个数据表中只能包含⼀个主键。你可以使⽤主键来查询数据。
    

4.1 database data types

* 数值类型
| 类型 | ⼤⼩ | ⽤途 |
| ------ | ------ | ------ |
| TINYINT | 1 字节 | ⼩整数值 |
| SMALLINT | 2 字节 | ⼤整数值 |
| MEDIUMINT | 3 字节 | ⼤整数值 |
| INT或INTEGER | 4 字节 | ⼤整数值 |
| BIGINT | 8 字节 | 极⼤整数值 |
| FLOAT | 4 字节 | 单精度 浮点数值 |
| DOUBLE | 8 字节 | 双精度 浮点数值 |
| DECIMAL | | ⼩数值 |
* ⽇期和时间类型
| 类型 | 格式 | ⽤途 |
| ------ | ------ | ------ |
| DATE | YYYY-MM-DD | ⽇期值 |
| TIME | HH:MM:SS | 时间值或持续时间 |
| YEAR | YYYY | 年份值 |
| DATETIME | YYYY-MM-DD HH:MM:SS | 混合⽇期和时间值 |
| TIMESTAMP | YYYYMMDD HHMMSS | 时间戳 |
* 字符串类型
| 类型 | ⼤⼩ | ⽤途 |
| ------ | ------ | ------ |
| CHAR | 0-255字节 | 定⻓字符串 |
| VARCHAR | 0-65535 字节 | 变⻓字符串 |
| TINYBLOB | 0-255字节 | 不超过 255 个字符的⼆进制字符串 |
| TINYTEXT | 0-255字节 | 短⽂本字符串 |
| BLOB | 0-65 535字节 | ⼆进制形式的⻓⽂本数据 |
| TEXT | 0-65 535字节 | ⻓⽂本数据 |
| MEDIUMBLOB | 0-16 777 215字节 | ⼆进制形式的中等⻓度⽂本数据 |
| MEDIUMTEXT | 0-16 777 215字节 | 中等⻓度⽂本数据 |
| LONGBLOB | 0-4 294 967 295字节 | ⼆进制形式的极⼤⽂本数据 |
| LONGTEXT | 0-4 294 967 295字节 | 极⼤⽂本数据 |

4.2 Operational Database

  • Use the procedure of the operation of the database php

    1. Built attention immediately and database links
    2. Using the sql statement to the database performing an operation -
    3. Getting Results
    4. And a link to the database is disconnected

1. Built attention immediately and database links

  • Using our in php mysql_connect () Remedies to build links and databases attention immediately
<?php
# 下⾯就是建⽴链接,$link 会得到⼀个链接信息
# $link = mysql_connect('ip地址', '数据库⽤户名', '数据库密码'); 
?>

We'll have a link $ link information can continue to operate the database

2. Determine which bank operations

  • Just be built and database links attention immediately, we have to determine which library operations
<?php
# 下⾯就是确定你要操作哪个库
# mysql_select_db('你要操作的库的名称', $link);
?>

3. Perform the operation of the database sql statement

<?php
# 下⾯就是使⽤ sql 语句对数据库进⾏操作
# $res = mysql_query('你要执⾏的 sql 语句'); 
?>

There are individual cases from ⼀ points to note:
we get a result ⼀ we do not understand the information processing
needs Using mysql_fetch_row || results to look at mysql_fetch_assoc resolve ⼀
have to understand

4. Close Links

  • Using the finish after all we are the best at close ⼀ database link
<?php
# mysql_close($conn);
?>

Complete step
step we complete the write operation to record the next

<?php
 $link = mysql_connect('localhost', 'root', 'root');
 mysql_select_db('test1913');
 $res = mysql_query('SELECT * FROM `student`');
 $row = mysql_fetch_assoc($res);
 mysql_close($link);
 print_r($row);
?>

The frequently-used sql statement

  • Just say the operation of the database sql statement how we look now at ⼀, when the operation of the database Frequently used
  • We are relying on these statements to sql database operations into ⾏

(1) query

<?php
# 查询 student 这个表⾥⾯的所有数据
 $sql = 'SELECT * FROM `student`';
# 查询 student 表中的数据⾥⾯ gender 为 男 的数据
 $sql = 'SELECT * FROM `student` WHERE `gender`="男"';
# 查询 student 表中的数据⾥⾯ age ⼤于 18 的数据
 $sql = 'SELECT * FROM `student` WHERE `age`>18';
# 查询 student 表中的数据⾥⾯ age ⼤于 18 且 gender 为 男 的数据
 $sql = 'SELECT * FROM `student` WHERE `age`>18 AND
`gender`="男"';
# 查询 student 表中的数据⾥⾯ age ⼩于 22 或者 age ⼤于 28 的数据
 $sql = 'SELECT * FROM `student` WHERE `age`<22 OR `age`>28';
# 查询 student 表中的数据⾥⾯从 第⼏条开始 查询多少条
 $sql = 'SELECT * FROM `student` LIMIT 0, 10';
# 先按照条件筛选出数据以后再进⾏分⻚查询
# 下⾯是查询表中所有 age>18 且 性别为男的所有数据,查出来以后从第 10 条
开始查 10$sql = 'SELECT * FROM `student` WHERE `age`>18 AND
`gender`="男" LIMIT 10, 10';
# 查询表的模糊查询
# 下⾯表示查询表中所有数据⾥⾯ name 字段中包含 "三" 字的数据
 $sql = 'SELECT * FROM `student` WHERE `name` LIKE "%三%"';
# 查询排序,查询的时候按照某⼀个字段升序或降序排序
 $sql = 'SELECT * FROM `student` ORDER BY `age` ASC';
 $sql = 'SELECT * FROM `student` ORDER BY `age` DESC';
?>

(2) increase Statement

<?php
# 向表中增加⼀条数据,再增加的时候主键不能由我们书写,⽽是 mysql 数据库
⾃⼰递增
 $sql = 'INSERT INTO `student` VALUES(null, "张三", 18, "男",
1913, 100)';
# 插⼊固定⼏个键的数据,其他的⽤默认值
 $sql = 'INSERT INTO `student` (`name`, `age`) VALUES("李四",
22)';
?>

(3) delete statement

<?php
# 删除表中 id 为 100 的数据
 $sql = 'DELETE FROM `student` WHERE `id`=100';
# 删除表中 name 为 张三 的数据
 $sql = 'DELETE FROM `student` WHERE `name`="张三"'
?>

(4) modification statements

<?php
# 更新⼀条 id 为 100 的数据中的 name 字段的值和 age 字段的值
 $sql = 'UPDATE `student` SET `name`="张三", `age`=10 WHERE
`id`=100'
# 更新数据的时候让所有的数据增加⼀些内容
 $sql = 'UPDATE `student` SET `age`=age+1'
?>

Finally, some frequently-used sql statement specification:

  • sql keyword zoomed write all
  • "Table" and "Field" Using the backtick package
  • In addition to the digital content and the Boolean Text is wrapped Use quotes

Knot: These are the key elements of the front and rear ends of the interaction, the next stage will be updated before and after interacting important tool for AJAX, like a small partner can thumbs, a wave of concern

Here Insert Picture Description

Released four original articles · won praise 55 · views 7449

Guess you like

Origin blog.csdn.net/Oriental_/article/details/104753399