thinkphp 条件搜索分页(tp自带Page类)
thinkphp 条件搜索分页:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
public function dadlist($request) { $npost = array_merge($_GET,$_POST); if(!empty($npost['status'])){ $dds['status'] = $npost['status']; } if(!empty($npost['ordernum'])){ $dds['ordernum'] = ['like',"%".$npost['ordernum']."%"]; } if(!empty($npost['preordernum'])){ $dds['preordernum'] = ['like',"%".$npost['preordernum']."%"]; } if(!empty($npost['userid'])){ $dds['userid'] = $npost['userid']; } $count = M('Dd')->where($dds)->count(); $Page = $page = new \Think\Page($count, 15,$npost); $show = $Page->show(); $list = M('Dd')->where($dds)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); //var_dump($list);die; $params = array( 'ddlist' => $list, 'count' => $count, 'Page' => $show, 'pageName' => '列表' ); return [1,$params]; }
——————————————