PHP头条
热点:

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


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

<form id="form1" name="form1" method="post" action="">
  1
  <input type="checkbox" name="checkbox[]" id="checkbox" value="1" />
  2
  <input type="checkbox" name="checkbox[]" id="checkbox2" value="2"  />
  3
  <input type="checkbox" name="checkbox[]" id="checkbox3" value="3" />
 
  <input type="submit" name="button" id="button" value="提交" />
</form>


<?
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.111cn.net 否则必究!
}

www.phpzy.comtrue/php/12945.htmlTechArticlephp mysql数据批量删除实现代码 我们一般是获取表单提交的数据,如果下面我们利用checkbox[]来操作,下面看实例。 -- form id=form1 name=form1 method=post action= 1 input type=checkbox name=checkbox[] id=c...

相关文章

    暂无相关文章
相关频道:

PHP之友评论

今天推荐