Paging help needed :-(
| From: | chris at planetoxygene dot com | Date: | Thu, 12 Jul 2001 07:49:08 +0000 |
| Subject: | Paging help needed :-( | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-10322@lists.php.net to get a copy of this message | ||
Hi there Everyone,
I currently have a dedicated Apache server with PHP 4.06, MySQL etc .. installed and running fine.
Below is alittle peice of code that I would love an answer to:
<?php
$connection = mysql_connect("Localhost","username!!!","password!!!")
or die("Couldn't make a connection.");
$db = mysql_select_db("planet", $connection)
or die("Couldn't select database.");
$sql = "SELECT id, email, name, subject, url, image2, comments, dat
FROM users
ORDER BY id DESC";
$sql_result = mysql_query($sql,$connection)
or die("Couldn't execute query.");
?>
<?
while ($row = mysql_fetch_array($sql_result)) {
$email = $row["email"];
$name = $row["name"];
$subject = $row["subject"];
$url = $row["url"];
$image2 = $row["image2"];
$comments = $row["comments"];
$dat = $row["dat"];
$comments=nl2br($comments);
include("censorguestbook.php");
$ip = getenv ("REMOTE_ADDR");
?>
then all the HTML and display bits (Example at www.planetoxygene.com in the guestbook).
<?
}
mysql_free_result($sql_result);
mysql_close($connection);
?>
Now my question is, how do I do paging in PHP? I need to display 10 entries per page, and be able
to go back and forth with them. I'm relatively new to PHP so I would be really grateful for
any advice.
Thanks everyone, I appreciate it.
Chris Payne
www.planetoxygene.com