thinkphp Keep query condition unchanged in the page
This post was last edited by Cffall on 2013-04-07 12:40:30
In the manual:
Import (' ORG. Util.page ');//Import page-out class
$mapcount = $User->where ($map)->count ();//query satisfies the required total number of records
$Page = new Page ($count, 25);//Instantiate the total number of incoming records for the paging class and the number of records displayed per page
When paging jumps, guarantee the query condition
foreach ($map as $key = = $val) {
$Page->parameter . = "$key =". UrlEncode ($val). ' & ';
}
$show = $Page->show ();//pagination display output
Here my query condition uses the in
$map [' code '] = Array (' in ', $array);
The query condition is unsuccessful when you click the second page. Isn't it possible to use in?
PHP page Out
------Solution--------------------
I've met the problem and found a way to solve it.
Import (' ORG. Util.page ');//Import page-out class
$count = $res->where ($sear)->count ();//query Data bar number
$Page =new page ($count, 2);//Instantiate paging function
When paging jumps, guarantee the query condition
foreach ($sear as $key = = $val) {
if (!is_array ($val)) {
$Page->parameter. = "$key =". UrlEncode ($val). " & ";//Assign a value to page
}
}
$show = $Page->show ();//pagination display output
A judgment was added here to implement the
------Solution--------------------
Inquire
Public Function Search () {
$res =d (' Info ');
$name =$_request[' name '];
$sear [' name '] = Array (' Like ', '% '. $name. ' %');
Import (' ORG. Util.page ');//Import page-out class
$count = $res->where ($sear)->count ();//query Data bar number
$Page =new page ($count, 2);//Instantiate paging function
When paging jumps, guarantee the query condition
foreach ($name as $key = = $val) {
$Page->parameter. = "$key =". UrlEncode ($val). " & ";//Assign a value to page
}
$show = $Page->show ();//pagination display output
This is the code that I used to query the page. You see, the one you just sent, although it can be found out, but it doesn't fit the rules.
This is my summary of the document http://blog.sina.com.cn/s/blog_80742e010101acfq.html, you see it