delete.php:
while($a=mysql_fetch_array($result)){
?>
<tr><td>
<input name="checkbox[]" type="checkbox" value="<?php echo $result['bookno'];?>" /></td>
<td><?php echo $a[0];?></td>
<td><?php echo $a[1];?></td>
<td><?php echo $a[2];?></td>
<td><?php echo $a[3];?></td>
<td><?php echo $a[4];?></td>
<td><?php echo $a[5];?></td>
<?php
}
?>
<tr><td><input type="submit" name="submit" value="删除" ></td>
<td><input type="hidden" name="bookno" value="<?php echo $select['bookno'];?>" /></td></tr>
delete1.php:
<?php
$mysqlhost = "localhost";
$mysqluser = "root";
$mysqlpass = "123456";
if($db = mysql_connect($mysqlhost,$mysqluser,$mysqlpass)){}
else{
throw new exception("sorry,could not connect to mysql.");
}
mysql_select_db('database',$db);
//echo $_POST['checkbox'][1];
if(isset($_POST['submit']) and $_POST['submit']=="删除" and $_POST['checkbox']!=""){ //判断是否执行删除操作
for($i=0;$i<count($_POST['checkbox']);$i++){ //遍历复选框获取到的新闻id序号
$sql=mysql_query("delete from book where bookno = '".$_POST['checkbox'][$i]."'"); //执行删除操作
}
if($sql){
echo "<script> alert('删除成功!'); window.location='delete.php'</script>";
}else{
echo "<script> alert('删除失败!'); window.location.href='delete.php'</script>";
}
}else{
echo "<script> alert('请选择要删除的内容!'); window.location.href='delete.php'</script>";
}
?>
根据我调试应该是执行删除操作这里的问题 就是不知道如何改 大神看看
delete.php的文件代码不完整,由于代码过多我发的核心会出问题的代码,delete1.php 是源码,求大神赐教!谢谢了