php mysqli怎么删除数据插图

本文操作环境:Windows7系统、PHP7.1、Dell G3电脑。

php mysqli怎么删除数据?

PHP MySQLi删除数据记录示例

代码如下:

<?php 
$host = 'localhost:3306'; 
$user = 'root';  // MySQL用户账号
$pass = ''; 
$dbname = 'test'; 
 
$conn = mysqli_connect($host, $user, $pass,$dbname); 
if(!$conn){ 
  die('Could not connect: '.mysqli_connect_error()); 
} 
echo 'Connected successfully<br/>'; 
 
$id=2; 
$sql = "delete from emp4 where id=$id"; 
if(mysqli_query($conn, $sql)){ 
 echo "Record deleted successfully"; 
}else{ 
echo "Could not deleted record: ". mysqli_error($conn); 
} 
 
mysqli_close($conn); 
?>

推荐学习:《PHP视频教程

以上就是php mysqli怎么删除数据的详细内容,更多请关注亿码酷站其它相关文章!


<!–亿码酷站直播班–>php mysqli怎么删除数据
—–文章转载自PHP中文网如有侵权请联系ymkuzhan@126.com删除

云服务器推荐