php老是提示id未定义,也获取不到传递的值 5
if(@$_GET['action']=='del'){$DelResult=mysql_query("DELETEFROMlanmuWHEREid='{$_POST['...
if (@$_GET['action']=='del') {
$DelResult=mysql_query("DELETE FROM lanmu WHERE id='{$_POST['id']}'") or die(mysql_error());
if ($DelResult){location('删除成功', 'aindex.php');}
}
<FORM method="post" name="del" action="aindex.php?action=del">
<table class="table table-hover">
<caption>网站栏目设置<button type="button" class="btn btn-success btn-sm">添加新栏目</button></caption>
<thead>
<tr>
<th>id</th>
<th>序号</th>
<th>栏目名称</th>
<th>删除</th>
<th>修改</th>
</tr>
</thead>
<tbody>
<?php while (!!$row=mysql_fetch_array($result,MYSQL_ASSOC)){?>
<tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['xuhao'];?></td>
<td><STRONG><?php echo $row['mingcheng'];?></STRONG></td>
<td><button type="submit" id="<?php echo $row['id'];?>" class="btn btn-danger btn-sm" >删除</button></td>
</tr>
<?php }?>
</tbody>
</table>
</FORM> 展开
$DelResult=mysql_query("DELETE FROM lanmu WHERE id='{$_POST['id']}'") or die(mysql_error());
if ($DelResult){location('删除成功', 'aindex.php');}
}
<FORM method="post" name="del" action="aindex.php?action=del">
<table class="table table-hover">
<caption>网站栏目设置<button type="button" class="btn btn-success btn-sm">添加新栏目</button></caption>
<thead>
<tr>
<th>id</th>
<th>序号</th>
<th>栏目名称</th>
<th>删除</th>
<th>修改</th>
</tr>
</thead>
<tbody>
<?php while (!!$row=mysql_fetch_array($result,MYSQL_ASSOC)){?>
<tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['xuhao'];?></td>
<td><STRONG><?php echo $row['mingcheng'];?></STRONG></td>
<td><button type="submit" id="<?php echo $row['id'];?>" class="btn btn-danger btn-sm" >删除</button></td>
</tr>
<?php }?>
</tbody>
</table>
</FORM> 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
2015-05-26
展开全部
麻烦吧具体错误提示贴出来,你的代码跟你的错误提示没多大关系吧。
更多追问追答
追问
错误提示: Notice: Undefined index: id in F:\wamp\wamp\www\bangong\admin\aindex.php on
line 6
追答
哦 $_POST['id']需要在isset检测一下或者加个@来屏蔽
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询