Page 1 of 1

What actually happens during pagination?

Posted: Mon May 02, 2005 10:49 pm
by BZorch
I have searched far and wide for an explanation to actually what happens when you paginate from an MySQL database using PHP. I have read many tutorials and I have figured out how to do it. But nothing ever discusses where the linked pages in the pagination are actually stored on the server, client, or elsewhere? Can anyone enlighten me?

Thank you.

Posted: Mon May 02, 2005 10:58 pm
by hawleyjr
A very basic level of pagination consists of the following variables:
  • A query
    Total Number of Records
    Records To display per page
    Current Low record

The rest is a matter of modifying the query to fit the parameters and determining what page you are currently on.

Also, make life easy. Use GET and not POST

Where are the temporary pages stored?

Posted: Tue May 03, 2005 7:03 am
by BZorch
Thank you. It does seem to be a straight forward process to create the pagination, but when you create the links for however many pages, where are the pages stored that the links reference. Since it dynamic and the pages are temporary and users are querying all of the time, are the pages in an array, cached in the browser, temp files on the server?

Posted: Tue May 03, 2005 7:46 am
by phpScott
if the pages are being dynamically created, say with php, then the pages don't exist anywhere because they haven't been created yet.

If the pages are static then they are still residing on the server waiting to be called.

When using pagination and php,mysql what happens is a request is sent to the server to pagination.php, or whatever, and it does a query something like

Code: Select all

Select * FROM myPages LIMIT $start, $numberOfRows
$start being where to start in the result set and $numberOfRows being how many rows of results to return. It is then up to you as the programmer to calculate the $start position of the rows to return based on things like a next link or an actual page number to jump to.

Hopefully that helps.

phpScott

I think I understand

Posted: Tue May 03, 2005 9:48 pm
by BZorch
Thank you. With your explanation and a little more detailed look at the scripts, I think I understand what is actually happening. Basically, the links added with the pagination script tell where to begin to display the records.

So when you click on each link the query is run again, but starts retrieving records at the specified point. So the start records are passed by the first query. So the results are always in the database and are not retrieved until needed. Is this correct? This is very helpful.