我们一般是获取表单提交的数据,如果下面我们利用checkbox[]来操作,下面看实例:
- 1
- "checkbox" name="checkbox[]" id="checkbox" value="1" />
- 2
- "checkbox" name="checkbox[]" id="checkbox2" value="2" />
- 3
- "checkbox" name="checkbox[]" id="checkbox3" value="3" />
- "submit" name="button" id="button" value="提交" />
- //开源:Vevb.com
- 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);
这样就实现的数据的批量删除.
新闻热点
疑难解答