我试图删除ID为1的计数器000004,但每次我删除所有000004在我的数据库中删除的记录。有什么问题?
PURCHASE_ORDER
counter | id |
000004 | 1 |
000004 | 2 |
000007 | 3 |
000005 | 4 |
rfq.php
if(isset($_GET['de']))
{
$del_id=$_GET['de'];
$sql1 = $mysqli->query("DELETE FROM purchase_order WHERE counter ='$del_id'");
if($sql1)
{
echo '<script type="text/javascript">window.history.go(-1);</script>';
}
}
这是发送ID的链接
rfq_list.php
<td align="center"><a href="rfq.php?de='.$row["counter"].'" onclick="return confirm(\'Really want to delete ?\');"></a></td>
答案 0 :(得分:0)
要指定多个删除条件,请使用AND
:
DELETE FROM purchase_order WHERE counter = '000004' AND id = 1;
答案 1 :(得分:0)
你可以尝试这样的事情。
<强> rfq_list.php 强>
<td align="center"><a href="rfq.php?id='.$row["id"].'&&de='.$row["counter"].'" onclick="return confirm(\'Really want to delete ?\');"></a></td>
此处,与counter value
一起,value of id
传递了<a href>
。
<强> rfq.php 强>
if(isset($_GET['de']) && isset($_GET['id']))
{
$del_id=$_GET['de'];
$id=$_GET['id'];
$sql1 = $mysqli->query("DELETE FROM purchase_order WHERE counter ='$del_id' and id='$id'");
if($sql1)
{
echo '<script type="text/javascript">window.history.go(-1);</script>';
}
}
delete
值为counter
000004
和id
= 1
的{{1}}记录。