As a front end must understand some basic database language, here I introduce a little simple SQL language.
The first is to increase:
1$mysql=new mysqli ("localhost", "root", "" "," H5class ");2$mysql -Query ("Setnames UTF8 ");3$sql="INSERT intoHtml5class (Name,age)VALUES('Li Ming',' -')";4$result=$mysql -query ($sql);5 if($result) {6 echo "Success";7}Else{8 echo "Failure";9}
This code is the first to create a new Mysqli object, the parameters are the server's address, database user name, password, database name. There is another way to do this:
< ? PHP // Assume database user name: root, Password:123456, database: Runoob $con=mysqli_connect ("localhost", "root" , "123456", "Runoob");? >
This is localhost because we use a local server, the default user name is generally root. For the INSERT into database table name (field 1, Field 2, ...) VALUES (' Value 1 ', ' Value 2 ', ...)
Delete:
1$mysql=new mysqli ("localhost", "root", "" "," H5class ");2$mysql -Query ("Setnames UTF8 ");3$sql="DELETE fromHtml5classWHEREName= 'Male Excellent'";4$result=$mysql -query ($sql);5 if($result) {6 echo "Delete succeeded";7}Else{8 echo "Delete failed";9}
Here is the DELETE from database table name where (condition).
Change:
1$mysql=new mysqli ("localhost", "root", "" "," H5class ");2$mysql -Query ("Setnames UTF8 ");3$sql="UPDATEHtml5classSETName= 'Male Excellent' WHEREAge= - ";4$result=$mysql -query ($sql);5 if($result) {6 echo "Success";7}Else{8 echo "Failure";9}
This is where the UPDATE database table name SET is to be modified where the Where condition (that is, the row to modify/filter).
Inquire:
1$mysql=new mysqli ("localhost", "root", "" "," H5class ");2$mysql -Query ("Setnames UTF8 ");3$sql="SELECT * fromHtml5classWHEREName= ' Millet'";4$result=$mysql -query ($sql);5 if($result) {6 echo "Query to";7}Else{8 echo "not queried";9}
Here is the SELECT * from database table name where condition. * Indicates all data, this can also be part of the data, such as:
SELECT from WHERE = "Millet";
These are basic database operations that can be built with these basic web sites.
SQL language (add and revise)