Home > Backend Development > PHP Tutorial > ThinkPHP让分页保持搜索状态的方法_PHP

ThinkPHP让分页保持搜索状态的方法_PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 11:52:12
Original
864 people have browsed it

ThinkPHP

对很多使用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就行了。

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
Latest Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template