Home >Backend Development >PHP Tutorial >How to implement thinkphp paging to maintain search status

How to implement thinkphp paging to maintain search status

WBOY
WBOYOriginal
2016-07-25 08:53:121009browse
  1. //Ensure query conditions when jumping by page
  2. foreach($map as $key=>$val) {
  3. $page->parameter .= "$key=".urlencode($val) .&;
  4. }
Copy the code

Debugging will find that when $map is not an array, the variable cannot get the desired value. The official idea is to traverse the encapsulated search conditions $map. Relatively speaking, it is better to directly traverse the data submitted by the form.

Modify the above code to:

  1. //Ensure query conditions when pagination jumps
  2. foreach($_get as $key=>$val) {
  3. //echo $key.$val;
  4. $page->parameter .= "$key=".urlencode($val).&;
  5. }
Copy the code

Problem solved.

Note that if the form is submitted by post, just traverse the post.



Statement:
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