Hello!
I want to do a search with pagination, but I don't know how to 'store' the data in the $_POST array, should I do it with sessions?
Rolensen
Hello!
I want to do a search with pagination, but I don't know how to 'store' the data in the $_POST array, should I do it with sessions?
Rolensen
Yes, you can use sessions or hidden fields and even better GET method in your form.
you should read some articles on this page: http://www.google.at/search?q=php+pagination+tutorial
If you are doing a search, you are trying to GET data from the server, and not send data to it -- which means you probably should use GET
, and not POST
.
Also, it would allow your users to bookmark the result pages (or send those links by e-mail, IM, ...), which is always nice ; and, also, use the back/forward buttons of the browser without getting an alert box, which is nice too ^^
(Oh, and, BTW, it would help solve your problem ;-) )
It is possible to use both GET and POST:
<form action="index.php?page=5">
So the pager links are submit buttons while rest of the data is stored in hidden fields. But that's not a good way to do this because you cannot pass someone link (on IM for example) to your search results.
But the best way is to store somewhere POST input data (look here: http://www.symfony-project.org/plugins/, when you input your query once, it is stored and remembered so you dont need to fill form multiple times)