不能删除指定的语句 总是从最后一个开始删除 奇怪啦
[code=PHP][/code]
form id="form1" name="form1" method="post" action="lianxi_ok.php">
<table width="75%" align="center">
<tr bgcolor="#0033CC">
<td width="24%" align="center">QQ</td>
<td width="32%" align="center">电话</td>
<td width="24%" align="center">地址</td>
<td width="32%" align="center">作者</td>
<td width="15%" align="center">删除</td>
</tr>
<?php
include("../conn.php");
$arr=mysql_query("select * from lianxi",$conn); //查询数据
/*使用while语句循环mysql_fetch_array()函数返回的数组*/
while($result=mysql_fetch_array($arr)){
?>
<tr>
<td><?php echo $result['QQ'];?></td>
<td><?php echo $result['tel'];?></td>
<td><?php echo $result['add'];?></td>
<td><?php echo $result['zuozhe'];?>
<input type="hidden" name="id" value="<?php echo $result['id'] ;?>" />
</td>
<td align="center"><label>
<input name="Submit" type="submit" value="删除" />
<a href="lianxup.php?id=<?php echo $result['id'];?>">编辑</a>
</label></td>
</tr>
<?php
} //结束while循环
?>
</table>
</form>
------解决方案--------------------
PHP code
include("../conn.php"); //包含conn.php文件
if(isset($_GET['id'])){
$delete=mysql_query("delete from lianxi where id='".$_GET['id']."'",$conn);
if($delete){
echo "<script> alert('删除成功!'); window.location.href='index.php'</script>";
}else{
echo "<script> alert('删除失败!'); window.location.href='index.php'</script>";
}
}