Home  >  Article  >  Backend Development  >  php批量删除数据_php技巧

php批量删除数据_php技巧

WBOY
WBOYOriginal
2016-05-17 09:41:33787browse

批量删除文章这个技术没什么高深莫测的,只是想写下来与大家分享。(适合初学者:)
1、首先在文章列表页面(list.php),将多选筐命名为:“$del_id[]”,值为文章ID号。
     例如(list.php):
  


          $result=mysql_query("select * from news");
        while($rs=mysql_fetch_array($result)){
     ?>
        " />=$rs[title]?>
             }
     ?>
   

2、处理页面(del.php):
       if($del_id!=""){
             $del_num=count($del_id);
             for($i=0;$i                 mysql_query("Delete from news where id='$del_id[$i]'");
             } 
             echo("<script>alert('删除成功!');history.back();</script>");
      }else{
             echo("<script>alert('请先选择项目!');history.back();</script>");
      }
    ?>  
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn