有人能帮助我吗?
here is my php script...
$req = mysql_query('SELECT id, email, start_date, end_date, time_event, time_submitted, payment_method, status FROM booking_members WHERE status="Canceled"');
while($dnn = mysql_fetch_array($req))
$req1 = mysql_query('DELETE FROM booking_members WHERE id='$id');
while($dnn1 = mysql_fetch_array($req1))
{
<td class="left"><center>
<a href="delete.php?id=<?php echo $dnn['id']; ?>"><img src="images/cross.png"></img></a>
</td></center>
如何从$ dnn ['id']获取id以删除行?
答案 0 :(得分:4)
为什么不直接运行删除?
DELETE FROM booking_members WHERE status='Cancelled'
绝对没有理由先选择所有的id然后循环遍历它们,一次删除一行。
答案 1 :(得分:0)
// ... PREVIOUS
while ($dnn = mysql_fetch_array($req)) {
$delete_id = $dnn['id'];
$req1 = mysql_query("DELETE FROM booking_members WHERE id='".$delete_id."'");
// ... CONTINUE
答案 2 :(得分:0)
while($dnn = mysql_fetch_array($req))
{? 在这里:
$req1 = mysql_query('DELETE FROM booking_members WHERE id='$id');
如果你想要最后一个查询的id,你必须这样做:$ dnn ['id']而不是$ id(或你之前设置$ id)... 并且,对于包含HTML脚本,在PHP脚本中,您必须使用echo或print或必须关闭标签php(?&gt;)
答案 3 :(得分:0)
如果你想查一查,我假设你正在使用dot net nuke,请下载免费报告模块。安装后,编辑它并输入以下select语句:
Select u.id,
u.username,
u.email,
b.start_date,
b.end_date,
b.time_event,
b.time_submitted,
b.payment_method,
b.status
FROM users as u
Join
booking_members as b on u.userid = b.userid
Where status="Canceled"'
这将显示用户名,电子邮件,start_date,End_date,Time_event,Time_submitted,Payment_method以及状态被取消的用户状态...