thinkphp3.2 分页和上下页

it2022-05-05  275

public function index(){ $p=I('get.p/d');//页码 if(!empty($seller_id)&&$seller_id!=' '){ $where1['seller_id']=$seller_id; $where1['is_del']=0; $seller_cash_model=M('seller_cash'); $count=$seller_cash_model->where($where1)->count(); $page=$this->getPage($count,10); $show=$page->show(); $order='posttime desc'; $totalPages=$page->totalPages;//取得分页页数 $list=$seller_cash_model->where($where1) ->order($order)->limit($page->firstRow,$page->listRows) ->select();//得出商品 //上下页 if($p<=1||empty($p)){ $lurl=$page->url(1); }else{ $lurl=$page->url($p-1); } if($p>=$totalPages){ $nurl=$page->url($totalPages); }else if(empty($p)){ $nurl=$page->url(2); }else{ $nurl=$page->url($p+1); } $this->assign('list',$list); $this->assign('order_res',$order_res); $this->assign('lurl',$lurl); $this->assign('nurl',$nurl); $this->assign('last_list',$last_list); $this->assign('last_list1',$last_list1); $this->assign('show',$show); $this->display(); } public function getPage($count=10,$number=8){ $page=new \Think\Page($count,$number); return $page; }

 


最新回复(0)