这篇文章介绍的内容是关于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中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号