PHP MySql add, delete, modify, check, phpmysql add, delete, modify
mysql_connect() connects to the database
mysql_select_db select database
mysql_fetch_assoc() gets the result set
mysql_query() executes sql statement
Examples are as follows:
$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))//Get the data for each row of the result set
{
echo "";
echo ""; echo $row['id' ];//Get the id in the row echo " | "; ;/td>";
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);
?>
Thank you for your support!
You can contact me for communication. Renhanlinbsl@163.com
Technorati Tags: PHP, Mysql, CRUD
http://www.bkjia.com/PHPjc/1135474.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/1135474.htmlTechArticlePHP MySql addition, deletion and modification query, phpmysql addition, deletion and modification mysql_connect() connects to the database mysql_select_db selects the database mysql_fetch_assoc() gets the result set mysql_query () Examples of executing sql statements are as follows:...