Msg#: 11494 posted 2:55 pm on Jan 23, 2006 (gmt 0)
There are a lot of pagination scripts out there.. I've used a number of canned ones, but lately I use a good one that I found and almost completely rewrote to suit my needs.
In a nutshell, you need to set a variable $limit to limit the query in question to a given number of rows, and use a $_GET variable $page to determine where you are at in the result set (what "page")
Make your display so that the appropriate links display. Do a little math and you can display only the next 5 or 6 and/or the previous 5 or 6 "pages"
One pitfall is that if your display is dependant on a $_POST to a form, you need to modify the script so that you get the same results with a $_GET. So your initial page will show the first x number of rows from a POST to a form, e.g. and the subsequent pages will use GET - e.g. example.com/widgetsearch.php?query=$this&page=$page
Msg#: 11494 posted 2:58 pm on Jan 23, 2006 (gmt 0)
Stil i dont see much script here becouse i dont know how it works anyways i use get on my forms when they get submitted i use a header to get the vars away and stuff (its easyer to create some standard hyperlinks that way)
Msg#: 11494 posted 6:13 pm on Jan 23, 2006 (gmt 0)
If you do SELECT SQL_CALC_FOUND_ROWS field, field... in your query with the limit, you can follow up with a SELECT FOUND_ROWS() to get the entire number. That way you don't have to worry about COUNT() queries. I've found it to be much, much faster to do it this way because the second query is read from cache.
Ex: Let's say you have a table with 1,000 rows...
SELECT SQL_CALC_FOUND_ROWS id, description FROM table LIMIT 0, 10 - Returns 10 records SELECT FOUND_ROWS() - Returns 1 record with a value of 1,000.