The Default code used to LIMIT the results fetched from the MySQL database using PHP is the following,
$sql="SELECT *
FROM `tablename`
WHERE `Type` LIKE '$var1'
LIMIT 0 , 30";
When we need to display results continuously we can alter that code with the following
$start=0; $end=30;
$start=$_GET['start'];
$end=$start+30;
$sql="SELECT *
FROM `tablename`
WHERE `Type` LIKE '$var1'
LIMIT $start , $end";
So I pass the value for the variable start with a link saying Next like this
<a href="something.php?start=<? $start+30 ?>">Next</a>
Everything goes fine when there are more results to display.
Consider this situation: There are 120 Entries in the Database and the PHP file is currently displaying results 91 to 120. So when I click the Next Link now it shows blank. So how can I make the "Next" link to be disabled when it is showing the last set of results? I think that could be possible if we know the total number of entries in the database. But if it is dynamic, how can we calculate it?
SELECT COUNT(*) FROM `tablename` WHERE `Type` LIKE '$var1'