前台代码:
<!DOCTYPE HTML>
<html>
<head>
<me
<me
<me
<li
<sc
<sc
<ti
</head>
<body>
<table class="table table-hover">
<caption>悬停表格布局</caption>
<thead class="color:red;font-size:1.2em;">
<tr class="success"><form method="post" action="__URL__/del_all" >
<th><input type="checkbox" id="checkall"/></th>
<th>编号</th>
<th>名称</th>
<th>城市</th>
<th>密码</th>
<th>时间</th>
<th>操作</th>
</tr>
</thead>
<volist name="info" id="vo">
<tbody>
<tr class="warning">
<td><input type="checkbox" name="id[]" value="{$vo.id}"/></td>
<td> {$vo.id}</td>
<td>{$vo.test1};</td>
<td>{$vo.test2};</td>
<td>{$vo.test3};</td>
<td>{$vo.create_time|date="Y-m-d H:i:s",###}</td>
<td><a href="__URL__/edit/id/{$vo.id}">修改</a>
<a href="__URL__/del/id/{$vo.id}">删除</a>
</td>
</tr>
</tbody>
</volist>
</table>
<input type="submit" class="btn btn-success" value="批量删除"/>
</form>
<sc
$(function(){
$("#checkall").click(function(){
if($("#checkall").prop("checked")){
$(":checkbox").prop("checked",true);
}else{
$(":checkbox").prop("checked",false);
}
})
})
</sc
</body>
</html>
后台:
public function del_all($ids=array()){
if (IS_POST){
$ids=$_POST['id'];
// print_r($ids);exit;
$where['id']=array("in",$ids);
$result=M('test')->where($where)->delete();
if($result){
$this->success('操作成功!');
}else{
$this->error('操作失败!');
}
}
}
