Copy code The code is as follows:
$dbhost='localhost';
$dbuser=' root';
$dbpass='123456';
$dbname='products';
$connect=mysql_connect($dbhost,$dbuser,$dbpass);
if(!$connect) exit('Database connection failed!');
mysql_select_db($dbname,$connect);
mysql_query('set names utf8');
//Query
$sql="SELECT * FROM `category`";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
echo $row['id'];
}
//Insert
$sql="INSERT INTO `category` (`id`,`name`) VALUES (NULL,'".$name."')";
$result=mysql_query($sql ;
}
//Modify
$sql="UPDATE `category` SET `name`='".$name."' WHERE `id`='".$id."'";
$result=mysql_query($sql);
if(mysql_affected_rows()){
echo 'Modification successful! ';
}
//Delete
$sql="DELETE FROM `category` WHERE `id`='".$id."'";
$result=mysql_query($sql) ;
if(mysql_affected_rows()){
echo 'Delete successfully! ';
}
//Close the connection
mysql_close($connect);
?>
http://www.bkjia.com/PHPjc/736854.html
www.bkjia.com
truehttp: //www.bkjia.com/PHPjc/736854.htmlTechArticleCopy the code as follows: ?php $dbhost='localhost'; $dbuser='root'; $dbpass= '123456'; $dbname='products'; $connect=mysql_connect($dbhost,$dbuser,$dbpass); if(!$connect) exit('data...