RE: [PHP] Showing 10 record items per page...?

From: Date: Tue, 17 Dec 2002 10:57:56 +0000
Subject: RE: [PHP] Showing 10 record items per page...?
Groups: php.general 
Request: Send a blank email to php-general+get-128531@lists.php.net to get a copy of this message
Hi David, > If I have lets say 30 items that match the query, > I would like the page to display this at the bottom > > Previous 10 page 1 2 3 Next 10 of 30 To get the 20 results starting at #100, your query will be something like "SELECT foo FROM bar LIMIT 100, 20" To do paged results with MySQL, have a variable (called $start or something) that keeps track of how many pages into the results you are, and increment or decrement it in the next and previous page links: <a href="results.php?start=<?=($start-1)?>">previous</a> <a href="results.php?start=<?=($start+1)?>">next</a> And construct your query along these lines: SELECT foo FROM bar LIMIT ($start * 20), 20 Hope this gets you started. Cheers Jon

« previous php.general (#128531) next »