Home > php教程 > php手册 > php mysql数据批量删除实现代码

php mysql数据批量删除实现代码

WBOY
Release: 2016-06-13 10:08:40
Original
1212 people have browsed it

我们一般是获取表单提交的数据,如果下面我们利用checkbox[]来操作,下面看实例。
-->


  1
 
  2
 
  3
 
 
 



if( $_post )
{
 print_r( $_post );
 //输也是以数据形式保存的,
 /*
 array
 (
  [checkbox] => array
   (
    [0] => 1
    [1] => 2
    [2] => 3
   )
 
  [button] => 提交
 )
 
 这样就好操作了,我们只要如下
 */
 $array = $_post['checkbox'];
 print_r( $array );
 /*
 得到内容如下
 
 array
 (
  [0] => 1
  [1] => 2
  [2] => 3
 )

 其实1,2,3就是我们想要的内容,我们就可以利用sql的in来批量实现删除了。
*/
 $ids = implode(',',$array );
 $sql ="delete from 表名 where id in($ids ) ";
 mysql教程_query($sql);
 
 //这样就实现的数据的批量删除哦。
 //本站原创转载注明来源http://www.bKjia.c0m 否则必究!
}

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