PHPMySql addition, deletion, modification, and query; phpmysql addition, deletion, modification, and PHP Tutorial

Source: Internet
Author: User
Add, delete, modify, and query PHPMySql. PHPMySql addition, deletion, modification, and query, phpmysql addition, deletion, modification, mysql_connect () connection database mysql_select_db select database mysql_fetch_assoc () obtain result set mysql_query () execute an SQL statement instance as follows: add, delete, modify, query

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:

$ Con = @ mysql_connect ('localhost', 'root', 'root'); // connect to the database
Mysql_select_db ('test', $ con); // select a database
$ UserInfo = mysql_query ("select * from user", $ con); // Create an SQL statement
Echo"










";While ($ row = mysql_fetch_assoc ($ userInfo) // obtain the data of each row in the result set{Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";}Echo"
";
Echo $ row ['id']; // obtain the id in the row
Echo"
";
Echo $ row ['username'];
Echo"
";
Echo $ row ['password'];
Echo"
";
Mysql_free_result ($ userInfo); // release the result set
Mysql_close ($ con); // closes 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 );
?>

Thank you for your support!

You can contact me. Renhanlinbsl@163.com

Technorati labels: PHP, Mysql, add, delete, modify, and query

Http://www.bkjia.com/PHPjc/1135474.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1135474.htmlTechArticlePHP MySql add delete modify query, phpmysql add delete change mysql_connect () connection database mysql_select_db select database mysql_fetch_assoc () get results set mysql_query () execute the SQL statement example is as follows :...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.