ThinkPHP method to keep pagination in search status_PHP tutorial

WBOY
Release: 2016-07-13 10:26:30
Original
764 people have browsed it

对很多使用ThinkPHP框架的人来说,使用自动自带的增删改查基类,在分页的时候要保持结果页面的搜索状态,但是使用thinkphp手册中的方案却无法奏效。

ThinkPHP手册中的解决方法是:

//分页跳转的时候保证查询条件
foreach($map as $key=>$val) {  
$Page->parameter  .=  "$key=".urlencode($val).&;
}
Copy after login

直接粘贴过来不能用,经过调试会发现,当$map不是一个数组的时候,那么变量是拿不到想要的值的,官方的思路是对封装好的搜索条件$map遍历,相对而言,对表单提交过来的数据直接遍历效果更好,于是,上面代码可改为:

//分页跳转的时候保证查询条件
foreach($_GET as $key=>$val) {
//echo $key.$val;
$page->parameter  .=  "$key=".urlencode($val).&;
}
Copy after login

问题解决,当然如果你的表单是POST提交的,遍历POST就行了。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/824658.htmlTechArticle对很多使用ThinkPHP框架的人来说,使用自动自带的增删改查基类,在分页的时候要保持结果页面的搜索状态,但是使用thinkphp手册中的方案却...
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!