The PEAR Pager class allows you to work with the PEAR database abstraction layer to created "pages" out of your results with little efoort.
<?php
require_once('DB.php');
require_once('Pager.php');
$dsn = "mysql://john:password@localhost/mydatabase";
$db = DB::Connect($dsn);
if(DB::isError($db)) {
die($db->getMessage());
}
$sql = "SELECT * FROM bigtable";
$result = $db->query($sql);
if(DB::isError($result)) {
die($db->getMessage());
}
$pager = new Pager($result, $from, $limit);
$data = $pager->build();
if(!$data) {
die("No Results");
}
while($row = $pager->fetchRow(DB_FETCHMODE_ASSOC)) {
/* Display content for page */
}
?>