1.循环遍历要删除的用户的或者呀删除的文章的id值:
<volist name="list" id="vo">
<tr id="sit_{$vo['id']}">
<td style="text-align: center;">
<a class="nspan" href="{:U('Owner/OwnerInfo?id='.$vo['id'])}">查看详情</a>
<a class="nspan" href="javascript:Del({$vo['id']});">删除</a>
</td>
</tr>
</volist>
2.用js提交要删除的id的值给后台方法
<script type="text/javascript">
function Del(id){
var data={id:id};
var setid="sit_"+id;
if(confirm("确定要删除此用户吗?")){
$.ajax({
type:"POST",
url:"{:U('Owner/DelOwner')}",
data:data,
dataType:"json",
success:function(msg){
if(msg==1){
alert("删除成功");
$("#"+setid).hide();
}else{
alert("删除失败");
}
},
error:function(msg){
}
});
}
}
</script>
3.定义后台删除方法
public function DelOwner(){
$cuser=M('cuser');
$id=I('param.id');
$return='0';
if(!empty($id)){
if($cuser->where(array('id'=>$id))->delete()){
$return='1';
}
}
$this->ajaxReturn($return);
}