Basic example: (handwritten in email client, syntax errors may exist) if (!isset($pagenum) || $pagenum < 0) { $pagenum = 0; } $range = 30; $start = $range*$pagenum; $end = $start + $range; $limit = " limit $start, $end"; $query = "select * from $table where host='$somename'$limit";
Then just pass the pagenum around. You'll probably want to pull another query that just gets the count(), and use that and some basic math to make the page range(s) to create hyperlinks. Cheers. - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 24, 2004 2:20 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] how to implement "pages" of results Hi, I'm sure this is a common question, so please forgive if it's been posted before. I have a select statement that selects records from a table: "select * from $table where host='$somename'" I then propagate a table with the returned data. My goal is to only display 30 records per "page", with links on each page that take the user to the next and previous 30 records. I have played around with using "limit", but this seems to only get me the next 30. How to achieve the previous 30? It would be easy if the records returned were sequentially numbered...but, since I'm being selective in which records I return (host=$somename), this is not the case. The first row may be 1, and the second row may be 10, etc. Anyone have any ideas on how to solve this? Thanks! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php