Simple instance for adding, deleting, modifying, and querying in PHPMySql, and adding and deleting instances in phpmysql. PHPMySql adds, deletes, modifies, and queries simple instances. phpmysql adds and deletes instances mysql_connect () connects to the database mysql_select_db and selects the database mysql_fetch_assoc () to obtain the result set mysql_query () for simple instances that execute SQL statements for adding, added or deleted instances in phpmysql
Mysql_connect () connecting to the database
Mysql_select_db select database
Mysql_fetch_assoc () to obtain the result set
Mysql_query () execute SQL statements
Example:
<? Php $ con = @ mysql_connect ('localhost', 'root', 'root'); // connect to the database mysql_select_db ('test', $ con ); // select database $ userInfo = mysql_query ("select * from user", $ con); // create SQL statement echo"
"; While ($ row = mysql_fetch_assoc ($ userInfo) // obtain the data of each row in the result set {echo"
"; Echo"
"; Echo $ row ['id']; // obtain the id echo in the row" | "; Echo"
"; Echo $ row ['username']; echo" | "; Echo"
"; Echo $ row ['password']; echo" | "; Echo"
";} Echo"
"; Mysql_free_result ($ userInfo); // release the result set mysql_close ($ con); // Close the database/* delete $ d = @ mysql_connect ('localhost', 'root ', 'root'); mysql_select_db ('test', $ d); mysql_query ("delete from user where id = 1", $ d); mysql_close ($ d ); * // * insert $ I = @ mysql_connect ('localhost', 'root', 'root'); mysql_select_db ('test', $ I ); mysql_query ("insert into user (username, password) values ('AD', 'AD')", $ I); mysql_close ($ I); * // update $ U = @ mysql_connect ('localhost', 'root', 'root'); mysql_select_db ('test', $ u ); mysql_query ("update user set username = 'AAA' where username = '00'", $ u); echo "update user set username = 'Ax 'where id = 2 "; mysql_close ($ u);?>
The simple example of the above PHP MySql addition, deletion, modification, and query is all the content shared by the editor. I hope to give you a reference and support for the help house.
Http://www.bkjia.com/PHPjc/1136618.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1136618.htmlTechArticlePHP MySql add delete modify query simple instance, phpmysql add delete instance mysql_connect () connection database mysql_select_db select database mysql_fetch_assoc () get results set mysql_query () execute SQL...