PHP mysql_query()函数用于删除表中的记录。从PHP 5.5开始, 不推荐使用mysql_query()函数。现在建议使用两种替代方法之一。
- mysqli_query()
- PDO :: __ query()
<
?php
$host = 'localhost:3306';
$user = '';
$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);
?>
输出
Connected successfully
Record deleted successfully
推荐阅读
- PHP MySQL ORDER BY排序语句
- PHP MySQL插入记录
- PHP MVC架构
- PHP MySQL创建表
- PHP MySQL连接示例
- chkdsk工具怎样修好,图文详细说明chkdsk工具怎样修好磁盘
- ie清除缓存,图文详细说明ie清除缓存办法
- 桌面不见了,图文详细说明桌面图标不见了怎样办
- tenda路由器设置,图文详细说明腾达无线路由器WiFi密码设置办法