You would define at the bottom a Limit. For the first page:
LIMIT 0,100
Second Page
LIMIT 100,100
and so on.
When you go to put the 'Next' link on the page, make a $_GET parameter that says start=100. Then, use that start parameter as the first value in limit, and add 100 to it to get the second value.
So, in the end it would look like:
if(empty($_GET['start']))
{
$start = 0;
}
else
{
$start = $_GET['start'];
}
$SQL = "SELECT * FROM TABLE WHERE 1=1 LIMIT ".$start.",100;";
query($sql);
$link = "<a href=\"?start=".$start+100."\">Next</a>";
If you wanted to expand upon that further, you could add a num parameter. That would allow for users to control how many records they see. So:
if(empty($_GET['start']))
{
$start = 0;
}
else
{
$start = $_GET['start'];
}
if(empty($_GET['num']))
{
$start = 100;
}
else
{
$start = $_GET['num'];
}
$SQL = "SELECT * FROM TABLE WHERE 1=1 LIMIT ".$start.",".$num.";";
query($sql);
$link = "<a href=\"?start=".$start+100."&num=".$num."\">Next</a>";
Of course, you would want to sanatize/validate all those numbers.