thinkphp to keep the query condition unchanged in the page

Source: Internet
Author: User
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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.