PHP Operations Database
Querying data
First step: Build a connection
Variable name = @mysql_connect ("Server", "User name", "password");//@: Mask suppression hint
$a = mysql_connect ("Locslhost", "Root", "");
Step two: Select the database you want to manipulate
mysql_select_db ("Database name", connection);
mysql_select_db ("Ren", $a);
Step three: Write SQL statements
Variable name = "SELECT * from table name";
$b = "SELECT * from Daihao";
Fourth step: Execute SQL statement, return result set
Variable name = mysql_query (SQL statement);
$c = mysql_query ($b);
Fifth step: Reading data from the result set
while ($d = Mysql_fetch_row ($c))
{
Var_dump ($d);
}
Mysql_fetch_array () ———— indexed by column name
MYSQL_FETCH_ASSOC () ———— returns an associative array
Mysql_fetch_object () ———— return object
Mysql_fetch_row () ———— returns an indexed array
Delete and change data
First step: Build a connection
Variable name = @mysql_connect ("Server", "User name", "password");//@: Mask suppression hint
$a = mysql_connect ("Locslhost", "Root", "");
Step two: Select the database you want to manipulate
mysql_select_db ("Database name", connection);
mysql_select_db ("Ren", $a);
Step three: Write SQL statements
Variable name = "INSERT into table name values (' Value ', ' value ')";
$b = "INSERT into Daihao values (' n008 ', ' Dai ')";
Fourth step: Execute SQL statement, return result set
Variable name = mysql_query (SQL statement);
$c = mysql_query ($b);
Fifth step: Reading data from the result set
Var_dump ($c);
Example:
1. Add Data
Build a submission page first
Build another processing page (because it is a processing page, you can only have PHP code)
Show Results:
2. The following pull mode query display data
Show Results:
3. Delete data in list mode
Build a list page first
Build a Process page again
Show Results:
PHP-----Simple Operations Database