thinkphp Keep query condition unchanged in the page

Source: Internet
Author: User
In the manual:
Import (' ORG. Util.page ');//Import Paging 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 in the paging class and the number of records displayed per page//paging jumps to ensure that 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?


Reply to discussion (solution)

Just UrlEncode is not enough, but first JSON or serialize

foreach ($map as $key = + $val) {    $Page->parameter   . =   "$key =". UrlEncode (Json_encode ($val)). ' & ';}

Change to this or not!

Where does your $array come from $_get $_post or $_request

My $array here is to use a parameter in the $_post to query an array of field values from a table in the database.

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

The contents of your array are:
$map [' code '] = Array (' in ', $array);

But the query criteria are:
"$key =". UrlEncode ($val). ' & '

Of course not.

This one's still not working.

foreach ($map as $key = = $val) {
$Page->parameter. = "$key =". UrlEncode ($val). ' & ';
echo "$key =". UrlEncode ($val). " & "; Output to see if it's all right?
}

I'm looking for a way out.
When paging jumps, guarantee the query condition
foreach ($map as $key = = $val) {
$Page->parameter. = "$key =". UrlEncode ($val). ' & ';
}
"$key =". UrlEncode ($val). ' & '; This $val means your condition.
Your is $map[' code ' = Array (' in ', $array);
Then change it.
foreach ($map as $key = = $val) {
$Page->parameter. = "$key =". UrlEncode ($code). ' & ';
}

You cannot be in foreach ($map as $key + = $val) {
Have a look at $map before (Print_r ($MAP))
When you know how to save data, don't you know what to do?

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

Thank you, but it's still not working.
I took a closer look at the source of the page.class.php, the Page->show method will be page->parameter processing. The parameter property supports 2 ways of passing values: strings and arrays. String using Var1=val1&var2=val2 ... The format. Please see the source of the processing:

$url  =  $_server[' Request_uri '). ( Strpos ($_server[' Request_uri '), '? ')? ': '? '). $this->parameter;        $parse = Parse_url ($url);        if (Isset ($parse [' query '])) {            parse_str ($parse [' query '], $params);            Unset ($params [$p]);            $url   =  $parse [' Path ']. Http_build_query ($params);        }


It is true that these conditions cannot be dealt with in, like, between.

How do you solve the landlord, please?

  • Related Article

    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.