kieranbarnes do you know where your towel is?

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

untitled.JPG

Easy.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Related posts:

  1. Nicer Pagination with ADOdb
    Or should that be Nicr? To follow in an annoying theme. Olavo Alexandrino wrote a...
  2. XHTML Transitional Compliant Paging with ADOdb
    Following on from my previous post, I've cleaned up the getNavigation() function to generate XHTML...
  3. JPGraph Part 1
    I really like JPGraph now. For too long I hated it as a clunky, bloated...
  4. Retro Fitting X10 Downlights
    I recently fitted a series of 8 recessed downlights in my living room. It wasn't...
  5. Idiot Proof Lightbox
    I've just made some modifications to my Gallery code which is part of i9000's small...

What this article 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.

Filed under: MySQL, PHP Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.