//批量删除
function del_much(){
$model = M('article');
$id = $_GET['id'];
$xiaojai = explode(',',$id);
$id = explode(',',$id);
$id_jzc = array_pop($id);
//var_dump($id);
//exit;
//判断id是数组还是一个数值
if(is_array($id)){
$where = 'id in('.implode(',',$id).')';
}else{
$where = 'id='.$id;
}
$list=$model->where($where)->delete();
if($list!==false) {
$this->success("成功删除{$list}条!",U('Index/show'));
}else{
$this->error('删除失败!');
}
}<include file="Public/header" />
<body>
<div style="height:1500px;width:100%;margin:0 auto;">
<include file="Public/header-1" />
<div style="height:600px;width:75%;margin:0 auto;margin-top:1%;">
<include file="Public/left_menu" />
<div style="min-height:600px;width:75%;margin:0 auto;float:right;">
<table style="width:100%;border:1px solid #FFC125" cellspacing="0" cellpadding="0">
<tr class="top_tr">
<th width="4%"><input type='checkbox' id="all" ></th>
<th width="5%" >序号</th>
<th width="50%">标题</th>
<th width="10%">所属栏目</th>
<th width="20%">时间</th>
<th width="11%" align="center">编辑 | 删除</th>
</tr>
<volist name="list" id="vo">
<tr class="list">
<td><input name='id[]' type='checkbox' value='{$vo.id}' ></td>
<td>{$vo.id}</td>
<td style="text-align:left;"><a href="__URL__/article?id={$vo.id}">{$vo.title|subtext=25}</a> </td>
<td>
<if condition="($vo.type eq 0)">动态
<elseif condition="$vo.type eq 1"/>指导
<else />常识
</if>
</td>
<td>{$vo.ctime}</td>
<td><a href="__URL__/modify?id={$vo.id}">编辑</a>
|
<a href="__URL__/del?id={$vo.id}" onclick="if(confirm('确定删除?')==false)return false;">删除</a>
</td>
</tr>
</volist>
</table>
<div class="pagination">{$page}</div>
<div><button class="piliangshanchu fanhui">批量删除</button></div>
</div>
</div>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Js/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(".prev").text("上一页");
$(".next").text("下一页");
$(".end").text("尾页");
var first=$(".current").text();
if(first==1){
$(".current").text("首页");
}
$(function(){
$("#all").click(function(){
if(this.checked){
$(".list :checkbox").prop("checked", true);
}else{
$(".list :checkbox").prop("checked", false);
}
});
$(".piliangshanchu").click(function(){
var ids = '';
$("input[name='id[]']:checkbox:checked").each(function () {
ids += $(this).val() + ',';
})
if(confirm("确认要删除?")){
window.location.href = "__URL__/del_much?id="+ids;
}
})
$(".del").click(function(){
var id = $(this).attr('data_id');
var delUrl = "__URL__/del";
if(confirm("确认要删除?")){
$.ajax({
url:delUrl,
data:{'id':id},
datatype:'json',
type:'post',
success:(function(data){
//jsondata = $.parseJSON(data);
//console.log(jsondata);
if(data.status == 1){
alert("删除成功!");
location=location;
}else{
alert("删除失败!");
}
})
})
}
})
$(".logout").click(function(){
var name = "{$loginname}";
var url = "__ROOT__/admin.php/Home/Login/logout";
$.ajax({
url:url,
data:{'name':name},
datatype:'json',
type:'post',
success:function(res){
if(res.status == 1){
alert("恭喜您,退出成功!");
window.location.href="__ROOT__/admin.php/Home/Login/index";
}else{
alert("退出失败!");
}
}
})
})
})
</script>
</body>
</html>
最佳答案