📜  PHP mysql-delete

📅  最后修改于: 2020-10-09 00:58:50             🧑  作者: Mango

PHP MySQL删除记录

PHPmysql_query()函数用于删除表中的记录。从PHP5.5开始,不推荐使用mysql_query()函数。现在建议使用两种替代方法之一。

  • mysqli_query()
  • PDO :: __ query()

PHP MySQLi删除记录示例

';

$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