...

View Full Version : How to page records?



Dhuan
04-10-2009, 05:17 AM
how can i page mysql selected records? for example, i want each page to have only 10 records.

Fou-Lu
04-10-2009, 06:02 AM
Pagination is language dependant. MySQL has the advantage of a LIMIT clause, but by itself its pointless (for pagination purposes). What language are you developing in?

Dhuan
04-10-2009, 06:08 AM
What language are you developing in?

Html/Php.

Fou-Lu
04-10-2009, 06:20 AM
I have a PHP5 pagination class posted in the snippets. Its somewhat advanced and assumes that whomever is incoporating it is familiar with callback routines and data handling.

Pagination is a rather simple process, but does require calculations in order to determine where to draw from and how far to go (recordcount wise). For this reason, it is really easy to get lost.
Here is a pretty good link I found on about: http://php.about.com/od/phpwithmysql/ss/php_pagination.htm
Its a simple example of pagination. Start easy, work up to complex ;)


Actually, I lied thats not a very good example. It makes use of long past deprecated features like register_globals.
Specifically, the $pagenum doesn't exist, it should be in an if/else:


if (!isset($_GET['pagenum']))
{
$pagenum = 1;
}
else
{
$pagenum = (int)$_GET['pagenum'];
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum