php pagination when using post data

Status
Not open for further replies.

matthew1471

New member
May 13, 2007
242
0
0
Bournemouth, UK.
I have a table which is populated with data from a form using post.

How can I paginate the table? As soon as the user clicks the link to go to the next page (a get yyy.php?page=x), the post'ed table data will be lost.

Any pointers?
 


there are several ways to do this...

you could store the data in a php session so the information is available on any page the user clicks

you could parse the data into a hidden form and use submit buttons as your previous next/buttons

you could pass the data via $_GET query string to the next page (although very messy)

you could store the date in a temporary mysql database table..

......
 
Here's an idea: store your shit in a fucking database after the POST and paginate using GETs with database record offsets and limits.
 
Edit:

Just re read the question.

Yes store that shit in a database to pick up later, that's probably the easiest.
 
Your data should be a in a table...

and after you learn mysql learn how to use the LIMIT parm on your queries. Tells the DB which record to start returning in your recordset and how many records to return.
 
It makes the most sense to use the session variable if the data posted won't be stored permanently, doesn't need to be accessed by other sessions, and has a relatively small footprint. It's simple and cheap to implement. An RDBMS is massive overkill for what you seem to be describing; if it's a relatively large amount of data but scoped to the session sqlite would be more efficient in most cases.
 
You should be storing all data permanently. Your situation is probably different than mine however. I store everything because it's cheap for me to do so.
 
Afternoon,

Thanks for the replies!

After re-reading my original post, it doesn't really explain things very well :( :)

I have a database which the user can search by selecting up to 9 different fields from the form... I used post because I didn't want to end up with urls of yyy.php?a=1&b=2&c=3&d=4&e=5&f=6& etc etc

Some of the result sets can be upto 1000 records (depending on how specific their query is).

I suppose I could use GET and rewrite the url yyy.php/1/2/3/4/5/6/7/ and then do the usual pagaination with limit etc.

But I'd rather keep the POST I think, as it keeps the url shorter.
 
Status
Not open for further replies.