php如何操作才能批量删除数据库的数据

php如何操作才能批量删除数据库的数据我现在是想用html的<label>来做一个多选择,提交到php中应该用什么代码,才能执行数据库删除多条指定行?

sample code:
<?php 
     if($del_id!=""){ 
             $del_num=count($del_id); 
             for($i=0;$i<$del_num;$i++){ 
                 mysql_query("Delete from news where id='$del_id[$i]'"); 
             }  
             echo("<script type='text/javascript'>alert('删除成功!');history.back();</script>"); 
      }else{ 
             echo("<script type='text/javascript'>alert('请先选择项目!');history.back();</script>"); 
      } 
    ?>

追问

大佬,那个$del_id是表单提交的变量吗?

追答

对的。

温馨提示:答案为网友推荐,仅供参考