(list.php): 
<form action="del.php" method="post"> 
<?php 
$sql="select * from news where leibie='$leibieming'";
$r=$mysqli->query($sql); 
while($rs=$r->fetch_assoc()){ 
?> 
<input type="checkbox" value="<?=$rs[id]?>" /><?=$rs[title]?> 
<?php 

?> 
<input type="button" value="删除"">
</form> 
2、处理惩罚页面(del.php): 
<?php 
if($del_id!=""){ 
$del_num=count($del_id); 
for($i=0;$i<$del_num;$i++){ 
$mysqli->query("delete news.......");

echo("<script type='text/javascript'>alert('删除乐成!');history.back();</script>"); 
}else{ 
echo("<script type='text/javascript'>alert('请先选择项目!');history.back();</script>"); 

?> 在网上抄回来的,del_id 这个变量是怎么传递的?

解决方案 »

  1.   

    你抄漏了!
    <input type="checkbox" value="<?=$rs[id]?>" /><?=$rs[title]?>
    应为
    <input type="checkbox" name="del_id[]" value="<?=$rs[id]?>" /><?=$rs[title]?>另外
    if($del_id!=""){
    应改写为
    if(isset($_POST['del_id'])){
      $del_id = $_POST['del_id'];
      

  2.   

    还有
    <input type="button" value="删除"">
    改为
    <input type="submit" value="删除"">
    否则页面无法提交
      

  3.   


    删除的结果是  array 提示输出。
      

  4.   

    贴出你修改后的 php 代码
      

  5.   

    if(isset($_POST['del_id'])){
        $del_id=$_POST['del_id'];
        $del_num=count($del_id);
        for($i=0;$i<$del_num;$i++){
            $mysqli->query("delete news,newscontents from news inner join newscontents on news.Nid=newscontents.nid where news.Nid='$del_id'");
            echo $del_id.'删除';
        }}else{
        echo("<script type='text/javascript'>alert('请先选择项目!');history.back();</script>");
    }删除的执行语句。
      

  6.   

    <form action="delAllZhangJie.php"method="post">
    <?php
        $Name="国际新闻";
        $sql="select Nid,Title from news where Class='$Name' order by Nid desc";
        $csql=$mysqli->query($sql);
        while($rs=$csql->fetch_assoc()){
    ?>
            <input type="checkbox" name="del_id[]" value="<?=$rs['Nid']?>" />-<?=$rs['Nid']?>-<?=$rs['Title']?><br>
    <?php
        }
    ?>
        <input type="submit"  value="删除"">
    </form>
      

  7.   

    $mysqli->query("delete news,newscontents from news inner join newscontents on news.Nid=newscontents.nid where news.Nid='$del_id[$i]'");
            echo $del_id[$i].'删除';