Retro Fitting Record Pagination with ADOdb
Posted on January 2, 2008
For my first project of the New Year I had to retro-fit pagination controls to an existing ADOdb powered web application for a client of mine. Looking back at my previous post on this topic, it was relatively simple to add the required features. Hers's how I did it.
It's nice to see my original article still ranks high on Google.
First step, include the pagination class file.
require_once '../_common_includes/class.GenericEasyPagination.php';
Step two, define a couple of variables. The first block of code relates to the actual navigation, the second relates to the number of records to be shown per page.
if ($_GET["page"]!="") {
$page = $_GET["page"];
}
else {
$page = 1;
}
define('CURRENT_PAGE',$page);
define('RECORDS_BY_PAGE',50);
Step three, change your $conn->Execute() call to PageExecute(), like so
$rs = $conn->PageExecute($SQL,RECORDS_BY_PAGE,CURRENT_PAGE);
Finally, step four, the navigation links & images
$recordsFound = $rs->_maxRecordCount;
echo '<div class="table_footer">';
$GenericEasyPagination =& new GenericEasyPagination($page,RECORDS_BY_PAGE,"eng");
$GenericEasyPagination->setTotalRecords($recordsFound);
echo "Records: ".$GenericEasyPagination->getListCurrentRecords();
echo " of ".$recordsFound;
echo "<br />";
echo '</div>';
echo $GenericEasyPagination->getNavigation();
You should get something like this at the bottom
Easy.
Related posts
- Nicer Pagination with ADOdb
Or should that be Nicr? To follow in an annoying theme. Olavo Alexandrino wrote a... - XHTML Transitional Compliant Paging with ADOdb
Following on from my previous post, I've cleaned up the getNavigation() function to generate XHTML... - Retro Fitting X10 Downlights
I recently fitted a series of 8 recessed downlights in my living room. It wasn't... - JPGraph Part 1
I really like JPGraph now. For too long I hated it as a clunky, bloated... - Idiot Proof Lightbox
I've just made some modifications to my Gallery code which is part of i9000's small...


