2024年12月05日 建站教程
如何利用php语法+mysql语法从数据库中删除指定数据,下面web建站小编给大家简单介绍一下具体实现代码!
代码示列如下:
<?php $host = "localhost"; $user = "username"; $password = "password"; $db_name = "database_name"; $conn = mysqli_connect($host, $user, $password, $db_name); if(mysqli_affected_rows($conn) === -1) { die("Error: Connection failed!"); } $table_name = "users"; $id = $_GET['id']; $sql = "DELETE FROM $table_name WHERE id = $id"; //删除指定id $result = mysqli_query($conn, $sql); if(!$result) { die("Error: Could not delete record!"); } mysqli_close($conn); ?>
本文链接:http://so.lmcjl.com/news/18983/