php 自定义排序

不言
不言 原创
2023-03-24 08:38:01 870浏览

这篇文章介绍的内容是关于php 自定义排序,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下


html 页面

<td class="textcenter">
                  <input type="text" name="cat[order]" value="{$vo.order}" class="hy_input orders" orderid="{$vo.cat_id}" style="width:50px;" />
          </td>
js 页面
<script type="text/javascript">
     $(".orders").change(function(){
             var orderid = $(this).attr('orderid');
             var ordernum = $(this).val();
             $.post("{:U('Image/listorder')}",{"orderid":orderid,"ordernum":ordernum},function(data){
                      if(data.code==1000){
                           location.replace(location); 
                      }else{
                         alert(data.msg);
                      }
             },"json");          
     });
</script>

php页面:

/**
	 * 排序操作
	 */
	public function listorder(){
         if(IS_POST){
                $orderid = I("post.orderid",'','intval');
                $ordernum = I("post.ordernum",'','intval');
                if(empty($orderid)){
                    $ini=array(
                          'code'=>222,
                          'msg'=>'id不合法'
                    );
                    $this->ajaxReturn($ini);
                }
                $listresult = M('Cat')->where("cat_id={$orderid} and status=0")->find();
                if(empty($orderid)){
					$ini=array(
                          'code'=>223,
                          'msg'=>'id已失效'
                    );
                    $this->ajaxReturn($ini);
                }
                $arr =array();
                $arr['order']  = $ordernum;
                $result = M('Cat')->where("cat_id={$orderid}")->save($arr);
                if($result){
                    $ini=array(
                          'code'=>1000,
                          'msg'=>'操作成功'
                    );
                }else{
					$ini=array(
                          'code'=>224,
                          'msg'=>'操作失败'
                    );
                }
                $this->ajaxReturn($ini);
         }
	}

以上就是php 自定义排序的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。