Welcome to WebmasterWorld Guest from 220.127.116.11
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
Then you need to know how many rows you want to display per page... $limit
Then $totalrows / $limit should give you the total number of pages
I usually do a COUNT(*) query first to determine the $totalrows ... This may or may not be the best way to get the count...
Then a bit like...
$numofpages = $totalrows / $limit;
$pagetotal = ceil($totalrows / $limit);
$page = $_GET['page'];
$page = 1;
}// if empty $page
$limitvalue = $page * $limit - ($limit);
Then for the actual query that will return results, use
Then to display the links at the bottom, you need to do a lot of IF's to determine page state, etc.
Ex: Let's say you have a table with 1,000 rows...
- Returns 10 records
SELECT SQL_CALC_FOUND_ROWS id, description FROM table LIMIT 0, 10
- Returns 1 record with a value of 1,000.