利用thinkphp实现 批量删除

来源:互联网 发布:bi工程师和数据分析 编辑:程序博客网 时间:2024/05/22 08:29

勾选相应选项 进行批量删除

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script type="text/javascript">function MM_jumpMenu(targ,selObj,restore){ //v3.0  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");  if (restore) selObj.selectedIndex=0;}//全选function  a(){    var checkObj = document.all("cheboxId");    var cid=document.all("cid");    var flag=true;    for(var i = 0;i<checkObj.length;i++){      if (checkObj[i].checked==false)        flag=false;    }    if (flag==true) {      for(var i = 0;i<checkObj.length;i++)        checkObj[i].checked = false;    }    else if(flag==false){      for(var i = 0;i<checkObj.length;i++)       if (checkObj[i].checked==false) checkObj[i].checked = true;    }    if(!flag)      cid.checked=true;    else      cid.checked=false;  } function CommandConfirm1(){        if(window.confirm("你确定修改吗?")){            return true;        }else{        return false;        }        }  function CommandConfirm2(){        if(window.confirm("你确定删除吗?")){            return true;        }else{        return false;        }        }</script><link href="__PUBLIC__/css/body.css" rel="stylesheet" type="text/css" /><!-- <link href="__PUBLIC__/css/table_b.css" rel="stylesheet" type="text/css" /> --><link href="__PUBLIC__/css/tablecloth.css" rel="stylesheet" type="text/css" /><script type="text/javascript" href="__PUBLIC__/js/right.js"></script></head><body><!-- <input type="checkbox" id="cheboxId" name="checkName" /> 11111    <input type="checkbox" id="cheboxId" name="checkName" /> 2222    <input type="checkbox" id="cheboxId" name="checkName" /> 3333    <input type="button" value="全选" onClick="a()" />     <input type="button" value="反选" onClick="b()" /> --><form method='post' method="post" action="__URL__/delete">  <table width="70%" border="1" align="center">      <thead>        <th width="10%">           <input type="checkbox" name="all" onclick="a()" id='cid'></th>        <th width="30%">用户名</th>        <th width="20%">用户ID</th>        <th width="50%">部门编号</th>      </thead>      <volist name="list" id="vo">      <tr>        <td><input type="checkbox" name="user[]" id='cheboxId' value='{$vo.USER_ID}'></td>        <td>{$vo.username}</td>        <td>{$vo.USER_ID}</td>        <td>{$vo.DEPT_ID}</td>      </tr>      </volist>    </table>    <!-- <a href="{:U("Index/delete?id=$vo[USER_ID]")}" name="id" target="_self">; -->    <input type="button" name="bt1" value="修改" onclick="CommandConfirm1()" >    <input type="submit" name="bt2" value="删除" >  </form><!-- <table width="60%" border="1" align="center">     <tr>    <td width="33%">用户名</td>    <td width="38%">权限</td>    <td width="16%"> </td>    <td width="13%"> </td>  </tr>  <tr>    <td> </td>    <td>用户</td>    <td><form id="form1" name="form1" method="post" action="">      <input type="submit" name="button" id="button" value="修改" />    </form></td>    <td><form id="form2" name="form2" method="post" action="">      <input type="submit" name="button2" id="button2" value="删除" />    </form></td>  </tr>  <tr>    <td> </td>    <td>档案馆工作人员</td>    <td><input type="submit" name="button3" id="button3" value="修改" /></td>    <td><input type="submit" name="button10" id="button10" value="删除" /></td>  </tr>  <tr>    <td> </td>    <td> </td>    <td><input type="submit" name="button4" id="button4" value="修改" /></td>    <td><input type="submit" name="button11" id="button11" value="删除" /></td>  </tr>  <tr>    <td> </td>    <td> </td>    <td><input type="submit" name="button5" id="button5" value="修改" /></td>    <td><input type="submit" name="button12" id="button12" value="删除" /></td>  </tr>  <tr>    <td> </td>    <td> </td>    <td><input type="submit" name="button6" id="button6" value="修改" /></td>    <td><input type="submit" name="button13" id="button13" value="删除" /></td>  </tr>  <tr>    <td> </td>    <td> </td>    <td><input type="submit" name="button7" id="button7" value="修改" /></td>    <td><input type="submit" name="button14" id="button14" value="删除" /></td>  </tr>  <tr>    <td> </td>    <td> </td>    <td><input type="submit" name="button8" id="button8" value="修改" /></td>    <td><input type="submit" name="button15" id="button15" value="删除" /></td>  </tr>  <tr>    <td> </td>    <td> </td>    <td><input type="submit" name="button9" id="button9" value="修改" /></td>    <td><input type="submit" name="button16" id="button16" value="删除" /></td>  </tr></table><table width="60%" border="0" align="center">  <tr>    <td width="70%"> </td>    <td width="30%"><form name="form" id="form">      <select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">        <option>1</option>        <option>2</option>        <option>3</option>        <option>4</option>        <option>5</option>        <option>6</option>        <option>7</option>        <option>8</option>      </select>      页    </form></td>  </tr></table> --></body></html>


<?php// 本类由系统自动生成,仅供测试用途class IndexAction extends Action{    public function index(){    $this->display('index');    }    public function login(){    if(!IS_POST) halt('页面错误');$username=I('username');$pwd=I('pwd');$db=new Model('user');$user=$db->where(array('username'=>I('username')))->find();$list=$db->select();if(!$user||$user['password']!=$pwd){$this->error('密码错误');//dump($list);}$_SESSION['username']=$username;$this->success("登陆成功","force");    }    public function force(){$this->display('force');    }public function top(){$this->display('top');    }public function left(){$this->display('left');    }public function right(){$this->display('right');    }public function RightsList(){$db=new Model('user');$user=$db->select();$this->assign('list',$user);$this->display('RightsList');}public function delete(){$id = I('post.user');$ids = implode(',',$id);$user = M('user');if($user->where(array('USER_ID' => array('in',$ids)))->delete()){$this->success("删除成功");}// $user=$this->getActionName();// $id=$this->_request("id");// $db=M($user);// $result=$db->where(array("USER_ID"=>$id))->find();// dump($user);// if($result)// $this->success('删除成功');// else// $this->error('删除失败');}}




0 0
原创粉丝点击