laravel框架即点击改,批量删除,更新日志
来源:互联网 发布:手机淘宝里怎么开网店 编辑:程序博客网 时间:2024/05/21 10:37
<script src="jquery-1.7.2.min.js"></script> <center> <h2>商品列表</h2> <button id="insert">插入数据</button> <a href="rizhi">查看日志</a> {{Session::get('user')}} <table border=1 > <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"> <tr> <th><input type="checkbox" name="" id=""></th> <th>名称</th> <th>价格</th> <th>操作</th> </tr> @foreach($models as $v) <tr> <td><input type="checkbox" name="box" value="{{$v->id}}"></td> <td pid="{{$v->id}}"><span class="update">{{$v->goods_name}}</span></td> <td pid="{{$v->id}}"><span class="price">{{$v->goods_price}}</span></td> <td><a href="del?id={{$v->id}}">删除</a></td> </tr> @endforeach </table> <button class="pl">批量删除</button> </center> <script> $(function(){ $("#insert").click(function(){ location.href="insert"; }) //批量删除 $(".pl").click(function(){ var box = $("input[name='box']"); length =box.length; //alert(length); var str =""; for(var i=0;i<length;i++){ if(box[i].checked==true){ str =str+","+box[i].value; } } str= str.substr(1) //alert(str) location.href="del?id="+str; }) //即点击该 $(document).on("click", ".update", function () { var con = $(this).html(); var pid = $(this).parent().attr('pid'); //alert(pid) $(this).parent().html('<input type="text" value="'+con +'" class="input" pid="'+pid+'" />'); $("input").focus(); $(document).on("blur", ".input", function () { var goods_name = $(this).val(); pid = $(this).attr("pid"); //alert(pid) $(this).parent().html('<span class="update">'+goods_name +'</span>'); $.post("update",{goods_name:goods_name,pid:pid},function(msg){ //alert(msg) location.href="login_do"; }) }); }); //即点击该 价格 $(document).on("click", ".price", function () { var con = $(this).html(); var pid = $(this).parent().attr('pid'); //alert(pid) $(this).parent().html('<input type="text" value="'+con +'" class="input" pid="'+pid+'" />'); $("input").focus(); $(document).on("blur", ".input", function () { var goods_name = $(this).val(); pid = $(this).attr("pid"); //alert(pid) $(this).parent().html('<span class="update">'+goods_name +'</span>'); $.post("price",{goods_name:goods_name,pid:pid},function(msg){ //alert(msg) location.href="login_do"; }) }); }); }) </script>
后台处理
//删除 public function del(){ $id = Request::input('id'); $str = explode(",",$id); //var_dump($str);die; foreach($str as $v){ DB::table('goods')->where('id',"=","$v")->delete(); } $arr['content']="删除Id为".$id."数据"; $arr['date']=date("Y-m-d H:i:s"); $arr['u_id'] = Session::get('user'); DB::table('rizhi')->insert($arr); return redirect("login_do"); } //即点击该 public function update(){ $pid = Request::input('pid'); // echo $pid;die; $old = DB::table('goods')->where('id',"=","$pid")->first(); $old_name = $old->goods_name; $goods_name = Request::input('goods_name'); $res= DB::table('goods') ->where('id','=',$pid) ->update(array('goods_name' => $goods_name)); $arr['content']="Id为".$pid."数据将商品名".$old_name."修改为".$goods_name; $arr['date']=date("Y-m-d H:i:s"); $arr['u_id'] = Session::get('user'); DB::table('rizhi')->insert($arr); echo 1; //return redirect("login_do"); } //即点击该 价格 public function price(){ $pid = Request::input('pid'); // echo $pid;die; $old = DB::table('goods')->where('id',"=","$pid")->first(); $old_name = $old->goods_name; $goods_name = Request::input('goods_name'); $res= DB::table('goods') ->where('id','=',$pid) ->update(array('goods_price' => $goods_name)); $arr['content']="Id为".$pid."数据将价格".$old_name."修改为".$goods_name; $arr['date']=date("Y-m-d H:i:s"); $arr['u_id'] = Session::get('user'); DB::table('rizhi')->insert($arr); echo 1; //return redirect("login_do"); }
阅读全文
0 0
- laravel框架即点击改,批量删除,更新日志
- laravel框架即点击改,批量删除,更新日志
- laravel框架即点击改,批量删除,更新日志
- laravel框架即点击改,批量删除,更新日志
- laravel框架之即点即改、批量删除
- laravel之批量删除
- 批量删除.trc日志
- linq 批量更新删除
- mongodb 批量更新,删除
- jdbc批量插入、批量删除、批量更新
- JDBC批量插入、批量删除、批量更新
- JDBC批量插入、批量删除、批量更新
- jdbc批量插入、批量删除、批量更新
- jdbc批量插入、批量删除、批量更新
- jdbc批量插入、批量删除、批量更新
- dbc批量插入、批量删除、批量更新
- JDBC批量插入、批量删除、批量更新
- laravel框架总结 -- 软删除
- 1.matlab环境变量设置,基本数据类型和语法结构
- php时间戳选取设置(选取地理位置不同时间不同)
- python基础教程
- 实用github使用技巧
- 关于response函数的存在使alert失效的讨论,目的是弹出提示并且跳转带参数的页面
- laravel框架即点击改,批量删除,更新日志
- tf教程(六):Time travel with tf
- 分享几个查找小图标的网站,以下几个网站都可以搜索图标,可以下载png、jpg、gif、icon等格式,而且包含多个尺寸,背景颜色,做网页设计的一定要收藏哟。
- ubuntukylin中vim插件自动补全安装
- nginx下运行php的程序时返回200访问却是空白页问题的解决方法
- Kotlin-25.解构声明(Destructuring Declaration)
- eclips快捷键
- Html5与Css3颜色和选择器(五)
- Redis4.0源码解析--3种线性表