RE: [PEAR] PearDB/Pager - Duplicate record problem
| From: | Simon H | Date: | Sat, 12 Jan 2002 02:03:06 +0000 |
| Subject: | RE: [PEAR] PearDB/Pager - Duplicate record problem | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-661@lists.php.net to get a copy of this message | ||
Please excuse the typo in the SQL query...its late, and I'm tired. This
typo isn't there in real life...fixed below.
Simon H
-----Original Message-----
From: Simon H [mailto:simon.hamilton@ntlworld.com]
Sent: 12 January 2002 01:58
To: Pear-General
Subject: RE: [PEAR] PearDB/Pager - Duplicate record problem
Importance: High
Sensitivity: Private
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 FTPUsers');
$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, <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'] . '">
«
</a> ';
// Direct link to pages
foreach ($data['pages'] as $page => $start_row)
{
if ($page == $data['current'])
{
echo '
<a CLASS="border" href="' . $PHP_SELF .
"?sort=$sort&limit=$limit&from=$start_row" . '">
[' . $page . ']
</a> ';
}
else
{
echo '
<a CLASS="border" href="' . $PHP_SELF .
"?sort=$sort&limit=$limit&from=$start_row" . '">
' . $page . '
</a> ';
}
}
// Next button
echo '
<a CLASS="border" href="' . $PHP_SELF .
"?sort=$sort&limit=$limit&from=" . $data['next'] . '">
»
</a>';
echo ' Show
<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> 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
--
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