php custom sorting

不言
Release: 2023-03-24 08:38:01
Original
1381 people have browsed it

The content of this article is about PHP custom sorting, which has certain reference value. Now I share it with everyone. Friends in need can refer to it


html Page

<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(&#39;orderid&#39;);
             var ordernum = $(this).val();
             $.post("{:U(&#39;Image/listorder&#39;)}",{"orderid":orderid,"ordernum":ordernum},function(data){
                      if(data.code==1000){
                           location.replace(location); 
                      }else{
                         alert(data.msg);
                      }
             },"json");          
     });
</script>
Copy after login

php page:

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

The above is the detailed content of php custom sorting. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!