Marquez Design <mailto:smarquez@xxxxxxxxxxxxxxxxxx> on Wednesday, March 23, 2005 12:19 PM said: > I am wanting to paginate records from a MySQL Database. > I want there to be 5 records on a page, on multiple pages. > > Can someone point me in the right direction or show me a way to do > this? > > I can get five records on a page with a LIMIT statement, however, I > can not get it to show the first five, then put a "next" link to the > next 5 and so on. Since you're already using limit you're doing better than most. At this point you can do one of two things: 1. When the search is first executed get a count of all available records and display only the ones you want on your page. On each subsequent page (next/previous) return, using the LIMIT clause, only those records you need. With this technique you'll be able to show the user how many total pages there are instead of the using guessing as to when they'll reach the end of their search results. If you don't have a lot of results you might not care to go this route. One requirement with this option is that you must pass the total number of records during each next/previous page transition. This is to tell the page that you've already done the initial look up. 2. Use the LIMIT clause to return only the records you need. This is what you seem to be doing already. The only other piece to your puzzle is to send the starting point for the LIMIT clause on each page change. For the first page you probably had "SELECT ... FROM ... LIMIT 0,5". Considering we're on the first page the "previous" link will not be clickable since we can't go back any further. However, the "next" link will pass the value 5 to the page so that the limit clause knows to start at record 5 on the next pass. i.e. "SELECT ... FROM ... LIMIT 5,5". So... Page 0: previous <a href="page.php?start=5">next</a> Page 1: <a href="page.php?start=0">previous</a> <a href="page.php?start=10">next</a> Page 2: <a href="page.php?start=5">previous</a> <a href="page.php?start=15">next</a> etc. Of course, you'll need to pass all your search criteria (and any other data you need) within each link as well. HTH! Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php