Pager.php
| From: | Simon H | Date: | Fri, 28 Dec 2001 12:28:40 +0000 |
| Subject: | Pager.php | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-642@lists.php.net to get a copy of this message | ||
I have a query about the Pager Class, that I hope someone can help me with.
I've been 8 hours at this, and have almost given up...
Example pager code:
***********************************************************
// Display data (only few examples)
echo '<html><body>';
echo $data['numrows'] . ' Results found';
echo 'Page '. $data['current'] . ' of ' . $data['numpages'];
echo $data['limit'] . ' results per page';
// Next button
echo '<a href="'. "$PHP_SELF?from=" . $data['next'] .
'"> '
. $data['remain'] . ' next-></a>';
// Direct link to pages
foreach ($data['pages'] as $page => $start_row) {
echo "<a href='$PHP_SELF?from=$start_row'>$page</a>";
}
// Automatically fetch only the rows for this page.
// fetchInto() is also avaible
while ($row = $pager->fetchRow(DB_FETCHMODE_ASSOC)){
echo $row['id'] . "\n";
}
***********************************************************
When using "$PHP_SELF" to get the name of the file this code is being used
in, I have a problem. I already have existing arguments in the URL that get
lost in these hyperlinks.
Is there a way to put the whole URL, including arguments, into this area to
make the hyperlinks work properly for me.
Normally this might be simple, but since I want this to be reusable, the
existing arguments in the URL of the page being displayed will be different,
therefore this info needs to be gathered dynamically I guess.
I have tried $HTTP_GET_VARS, and $REQUEST_URI bu none of these seem to work
for some reason. Is it because it is an include or something?
I am still a bit tender when it comes to the fancy stuff like this, so
please be kind.
BTW, I really don't know how I could do without this class for any large
query results.
Merry Xmas! and a Happy New Year!!!!
Simon H
PS. I have tried to use this tool as a re-usable include, but when I try to
include a copy at the top, and at the bottom of the table data it doesn't
seem to like it. Is there a way around this? (not essential, but nice).