我尝试过各种方式但不起作用
option.php
if (isset($_GET['agentsdelete'])) {
$agents_id=$_GET['agents_id'];
$delete=$db->prepare("DELETE FROM agents WHERE agents_id=:agents_id");
$control=$delete->execute(array(
'agents_id' => $_GET['agents_id']
));
if ($control) {
Header("Location:agents.php??durum=ok&agents_id=$agents_id");
} else {
Header("Location:agents.php??durum=no&agents_id=$agents_id");
}
这是php脚本
的index.php
<a href="option.php?agentsdelete=<?php echo $agentget['agents_id']; ?>" class="btn btn-danger btn-sm btn-icon icon-left">
<i class="entypo-cancel"></i>
Delete
</a>
这个是index.php,其中是
中的按钮答案 0 :(得分:0)
<?php
if (isset($_GET['agentsdelete'])) {
$agents_id = $_GET['agentsdelete'];
$delete = $db->prepare("DELETE FROM agents WHERE agents_id= ? ");
if ($delete->execute(array(
$agents_id
))) {
Header("Location:agents.php??durum=ok&agents_id=$agents_id");
} else {
Header("Location:agents.php??durum=no&agents_id=$agents_id");
}
}
?>
答案 1 :(得分:0)
if (isset($_GET['agentsdelete'])) {
$agents_id = $_GET['agentsdelete'];
$delete = $db->prepare("DELETE FROM agents WHERE agents_id= ? ");
header('location:agents.php');
$delete-> execute();
}
这是足够的代码,请不要使其变得复杂。
非常简单。