Retro Fitting Record Pagination with ADOdb
January 2nd, 2008For 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.
| Bookmark it del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Propeller | Yahoo |
Was this post useful to you? Let me know, buy me a beer!
Alternatively, if you're feeling impecunious, you may like to subscribe to my RSS feed, or see other articles in the MySQL, PHP category.