当我尝试使用mysqli 从数据库中删除时遇到一些问题这里是我的代码
function delete() {
// get id value
$delete = $_GET['delete'];
// delete the entry
$query = mysqli_query($dblogin, "delete from admin where id=$delete");
// redirect back to the view page
header("Location: users.php");
}
if (isset($_GET['delete'])) {
delete();
}
将有人看一看,并帮助我:D
答案 0 :(得分:-1)
您忘记设置名为$ delete的参数。
function delete($dblogin, $delete) {
// delete the entry
$query = mysqli_query($dblogin, "delete from admin where id=$delete");
// redirect back to the view page
header("Location: users.php");
}
if (isset($_GET['delete']) || !empty(GET['delete'])) {
delete($dblogin, $_GET['delete']); // call the function
}