RE: [PEAR] PearDB/Pager - Duplicate record problem

From: Date: Sat, 12 Jan 2002 01:58:18 +0000
Subject: RE: [PEAR] PearDB/Pager - Duplicate record problem
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-660@lists.php.net to get a copy of this message
I have now discovered that its counting the number of records correctly, but it's leaving out the last record, and duplicating the first. Still no idea why. I have also since upgraded to v.1.2 and renamed the class to DB_Pager accordingly, but the update made no difference. (DB = ODBC to MS Access) Here's the pager code: <?php if ( $nav_pos == "top" ) { require "Pager.php"; PEAR::setErrorHandling(PEAR_ERROR_DIE); $db = DB::connect($dsn); $numrows = $db->getOne('select count(Name) from FTPUsers'); $res = $db->query($sql); if (!isset($limit) || !$limit) { $limit = 10; } $pager = new DB_Pager ($res, $from, $limit, $numrows); $url_test = $PHP_SELF . "?" . $QUERY_STRING; $data = $pager->build(); } elseif ( $nav_pos == "bot" ) { PEAR::setErrorHandling(PEAR_ERROR_DIE); $db1 = DB::connect($dsn); $numrows1 = $db1->getOne('select count(Name) from Users'); $res1 = $db1->query($sql); if (!isset($limit) || !$limit) { $limit = 10; } $pager_bot = new DB_Pager ($res1, $from, $limit, $numrows1); $url_test = $PHP_SELF . "?" . $QUERY_STRING; $data = $pager_bot->build(); } echo ' <!-- Table page Navigator - START --> <TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0"> <TR> <TD WIDTH="25%" ALIGN="left" CLASS="tbNAV"> <B>' . $data['numrows'] . '</b> results found,&nbsp;<B>' . $data['numpages'] . '</B> page(s) @ <B>' . $data['limit'] . '</b> per page </TD> <TD WIDTH="75%" ALIGN="right" CLASS="tbNAV"> <form name="limit" method="post" action="'. $PHP_SELF . "?sort=$sort" . '"> // Previous Button <a CLASS="border" href="' . $PHP_SELF . "?sort=$sort&limit=$limit&from=" . $data['prev'] . '"> &nbsp;&laquo;&nbsp; </a>&nbsp;&nbsp;'; // Direct link to pages foreach ($data['pages'] as $page => $start_row) { if ($page == $data['current']) { echo '&nbsp; <a CLASS="border" href="' . $PHP_SELF . "?sort=$sort&limit=$limit&from=$start_row" . '"> &nbsp;[' . $page . ']&nbsp; </a>&nbsp;'; } else { echo '&nbsp; <a CLASS="border" href="' . $PHP_SELF . "?sort=$sort&limit=$limit&from=$start_row" . '"> ' . $page . ' </a>&nbsp;'; } } // Next button echo '&nbsp;&nbsp; <a CLASS="border" href="' . $PHP_SELF . "?sort=$sort&limit=$limit&from=" . $data['next'] . '"> &nbsp;&raquo;&nbsp; </a>'; echo '&nbsp;&nbsp;&nbsp;&nbsp;Show&nbsp; <select CLASS="MS50" name="limit"> <option value="' . $data['limit'] . '" SELECTED>' . $data['limit'] . ' </option> <option value="1">1</option> <option value="10">10</option> <option value="25">25</option> <option value="50">50</option> <option value="75">75</option> <option value="100">100</option> <option value="' . $data['numrows'] . '">ALL</option> </select>&nbsp;lines per page <input CLASS="BUT1" type="submit" name="Submit" value="Go"> </form> </td> </tr> </TABLE> <!-- Table page Navigator - END -->'; ?> The above is sued as an include at the top and bottom of the table and works very well, apart from this duplicate forst record and no last record thingy. Thanks again, if anyone can help. Simon H -----Original Message----- From: Simon H [mailto:simon.hamilton@ntlworld.com] Sent: 11 January 2002 22:19 To: Pear-General Subject: [PEAR] PearDB/Pager - Duplicate record problem Importance: High Sensitivity: Private I'm using the Pear Pager to generate data from ODBC (MS Acess DB), but for some reason I always get a duplicate first record. (I'm using manual "$numrows" and no error checking as advised - The only way I could get it to work). Any help or ideas on what might cause this would be much appreciated. Thanks Simon H -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, e-mail: pear-general-unsubscribe@lists.php.net For additional commands, e-mail: pear-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.pear.general (#660) next »