delete.php:
include_once("conn\conn.php");
if (is_array($_POST['id'])) {
$id = join(',', $_POST['id']);
} elseif (is_numeric($_GET['id'])) {
$id = (int) $_GET['id'];
} else {
echo '数据不合法';
exit;
} $sql = "delete from padd where id in($id)";
$result = mysqli_query($connID, $sql);
if ($result) {
echo '删除成功';
} else {
echo '删除失败';
}
?>
index.php如下:
include_once("conn\conn.php");
$sql = "select * from padd order by id desc";
$result = mysqli_query($connID, $sql);
if ($result && mysqli_num_rows($result)) {
echo '';
} else {
echo '没有数据';
}
mysqli_close($connID);
?>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号