Home > php教程 > php手册 > body text

php批量删除数据

WBOY
Release: 2016-06-13 12:33:58
Original
924 people have browsed it

批量删除文章这个技术没什么高深莫测的,只是想写下来与大家分享。(适合初学者:)
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>");
      }
    ?>  
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template