View Full Version : Retrieve data and display multiple pages

Retired Bill
06-16-2006, 06:20 AM
I'm new at this. My needs exceed my current abilities. I would appreciate some help. I am retrieving data from my database and displaying the last 10 rows on a page. I would like to display all previous records rather than just the last 10. My code is as follows:

#connect to MySQL
$rs = @mysql_connect( "localhost", "user", "password" )
or die( "Could not connect to MySQL" );

#select the database
$rs = @mysql_select_db( "my_database" )
or die( "Could not select database" );

#create the SQL query

$sql = "select * from guestbook order by time desc limit 10";

#execute the query
$rs = @mysql_query( $sql )
or die( "Could not execute SQL query" );

#loop through all records
while ( $row = mysql_fetch_array( $rs ) )
<table class="archive" border="1" width="375">
<td><b>Name:</b> <?php echo $row["name"]; ?></td>

<td><b>Comments:</b> <?php echo $row["comments"]; ?></td>

How do I create multiple pages that contain all retrieved entries? Hope someone can help.

06-16-2006, 06:23 AM
why do you need multiple pages if every page is going to show all records? Wouldn't you just need a single page?

Retired Bill
06-16-2006, 06:36 AM
I'd like to retrieve more than the last 10 entries from my database and display them all.