Home > php教程 > php手册 > 分页带上查询参数

分页带上查询参数

WBOY
Release: 2016-06-07 11:44:47
Original
976 people have browsed it

刚刚使用,代码可以更加精简,但是在测试中出现了点问题,所以就将现在这个代码发布了,希望对大家有所启示.这个代码是为了在分页搜索时,附带查询条件
      public function index(){<br> <br>         $data=array();<br>         //省份<br>         $province=$this->_post('province');<br>         $province_=$this->_get('province_');<br>         if($province){<br>             $data['province']=array('like' , '%'.$province.'%');<br>         }<br>         if($province_){<br>             $data['province']=array('like' , '%'.$province_.'%');<br>         }<br>        <br>         $company=D('Company');<br>         $count_company=$company->where($data)->count();<br>         import('ORG.Util.Page');<br>         $page=new Page($count_company,15);<br>         $companys=$company->where($data)->order('id')->limit($page->firstRow.','.$page->listRows)->select();<br> <br>         //附加(URL)分页参数<br>         if($province){<br>             $page->parameter.="&province_=".$province;<br>         }<br> <br>         $this->assign('companys',$companys);<br>         $this->assign('page',$page->show());<br>         $this->display();<br>     }

AD:真正免费,域名+虚机+企业邮箱=0元

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template