我想从表组中删除一个组,但是我的代码没有从URL中获取ID。
请帮助我。 我是PHP的新手。
这是我的下面的代码...
<a href="mngt.php?btn-groups=Groups?delete=<?php echo $row['id'];?>" class="btn btn-sm btn-danger">Delete</a>
if (isset($_GET['delete'])) {
$id = $_GET['delete'];
$sql_id = "id";
$query_table = "groups";
$redirect = "mngt.php?btn-groups=Groups?group=deleted";
$class->delete($id, $query_table, $sql_id, $redirect);
}
//删除功能
public function delete($id, $query_table, $sql_id, $redirect){
$stmt = $this->connect()->prepare("DELETE FROM ".$query_table." WHERE ".$sql_id." = :id");
if ($stmt->execute(array(":id"=>$id))){
header('location: '.$redirect);
}
}