[英]PHP PDO DELETE BUTTON
I tryed every way but it does not work我尝试了各种方法但它不起作用
option.php
选项.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");
}
this is php script这是 php 脚本
index.php
索引.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>
and this one is index.php where button in而这个是 index.php where button in
<?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");
}
}
?>
if (isset($_GET['agentsdelete'])) {
$agents_id = $_GET['agentsdelete'];
$delete = $db->prepare("DELETE FROM agents WHERE agents_id= ? ");
header('location:agents.php');
$delete-> execute();
}
This is enough code, don't make it complicated.这是足够的代码,不要让它变得复杂。
It's very easy.这很容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.