Mysql删除功能不起作用

时间:2015-02-03 16:50:12

标签: php mysqli

当我尝试使用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

1 个答案:

答案 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
}