Home > Backend Development > PHP Tutorial > PHP MySql add, delete, modify, check, phpmysql add, delete, modify_PHP tutorial

PHP MySql add, delete, modify, check, phpmysql add, delete, modify_PHP tutorial

WBOY
Release: 2016-07-12 08:50:11
Original
1539 people have browsed it

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 ""; ;/td>";
              echo "
";
echo $row['id' ];//Get the id in the row
          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

TechArticlePHP 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:...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template