RE: [PHP-DB] howw do I programm a PREV & Next mechanism in PHP? Help Please!!
| From: | Charles Butler | Date: | Thu, 04 Oct 2001 21:10:02 +0000 |
| Subject: | RE: [PHP-DB] howw do I programm a PREV & Next mechanism in PHP? Help Please!! | ||
| References: | 1 | Groups: | php.db php.general |
| Request: | Send a blank email to php-db+get-13016@lists.php.net to get a copy of this message | ||
And ofcourse being myself, I totally forgot to insert the rest of the
code...many apologies... Here is the full code:
function NavLinks($limit, $offset, $user, $passwd, $dbname, $host,
$PHP_SELF) {
// Get a running total of news-id's so we can calculate and display the
Total number of news-entries
$tablename = "phantom_droid";
$connection = @mysql_connect($host, $user, $passwd) or die
(mysql_error());
$db = @mysql_select_db($dbname, $connection) or die (mysql_error());
$sql = "
SELECT id from $tablename
";
$result = @mysql_query($sql, $connection) or die (mysql_error());
$row_num = mysql_num_rows($result);
$total = ($row_num-1);
$next = $offset + $limit;
$prev = $offset - $limit;
$offset += $limit;
$next_disp = "<a href=$PHP_SELF?dest=home&offset=$next>Next
$limit</a>";
$prev_disp = "<a href=$PHP_SELF?dest=home&offset=$prev>Previous
$limit</a>";
if ($prev < 0) {
$prev_disp = "Previous $limit";
}
if ($next >= $total) {
$next_disp = "Next $limit";
}
$total_news_disp = "<font class=linkwannabe>$row_num Total News
Entries</font>";
// echo the display block
echo "$total_news_disp $prev_disp |
$next_disp ";
}
-----Original Message-----
From: Sander Peters [mailto:S.Peters@Visionnet.nl]
Sent: Thursday, October 04, 2001 3:44 PM
To: php-db@lists.php.net; php-general@lists.php.net
Subject: [PHP-DB] howw do I programm a PREV & Next mechanism in PHP?
Help Please!!
Hello!
I'm making a database wich can be viewed and modified through a
webbrowser using PHP and MySQL.
I users wants to browse records from my (mysql) database, and the user
can decide how many records he/she wants to see per page. There should
be a Previous and a Next button on each page to brows through the
records.
(This is a very common situation wich is for example used by search
engines.)
My problem is, I really don't know how to make a Prev and Next system. I
tried already a lot but it doesn't work.
Does somebody have a PHP script with this working and can you send it to
me please (or just the part with the prev/next meschanism)?
It would help me a lot!
Thanks in advance!
Greetings
Sander Peters - The Netherlands
http://www.visionnet.nl/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net