PHP search paging problems

Source: Internet
Author: User
I have been troubled by the paging problem in PHP search for many days. I have thought of many ways to store the searched data with variables. but I don't know if there are 3-4 conditions. why ?? Thank you for your discussion? Action = search & amp; username = name & amp; page = 2, $ SESSION ['usernam PHP search paging problem
This problem has plagued me for many days. I thought of a lot of ways and thought of storing the searched data with variables. But no, there are 3-4 conditions. why ?? Thank you.



------ Solution --------------------
Discussion

? Action = search & username = name & page = 2



------ Solution --------------------
$ SESSION ['username'] =_ _ POST ['username'];
If you write it like this, the value will be washed out every time you click the next page .. (Because there is no post request when you click the next page, $ _ POST ['username'] does not exist), so this is an incorrect method.
If you must use the session, you can add a judgment so that you can register the session only when you click search.

Session_start ();
If (strtolower ($ _ REQUEST ['method']) = 'post') {// Click to search
$ _ SESSION ['username'] =_ _ POST ['username'];
}


The simplest method is not to use session.
$ Username = isset ($ _ POST ['username'])? $ _ POST ['username'] :( isset ($ _ GET ['username'])? $ _ GET ['username']: '');

Connection

? Action = search & username = {$ username} & page = 2;
In this way, no loss is guaranteed.

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.