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 ------ solution ------------------ discuss? Actionsearch & amp; username & amp; page2 ------ solution ------------------ $ SESSION [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.