Here's a function to map out your page indexes...
function getResultPages($resultCount,$resultLimit) {
// do we need to do the links to other results? //
if ($resultCount > $resultLimit) {
//OK... calculate number of pages needing links //
$numPages = intval($resultCount/$resultLimit);
/
$numPages now contains amount of pages needed.
Unless there is a remainder from the division
so we check for that next...
/
if ($resultCount%$resultLimit) { // has remainder so add one page
$numPages++;
}
for ($i=1; $i<=$numPages; $i++) {
/*
Here we loop thru results and create
an array of pages and offsets to pass back
*/
$pageArray[$i]['OFFSET_PAGE_LINK'] = $resultLimit * ($i-1);
}
} else {
// then we had no extra pages so we pass a 1 element null value array
$pageArray[0]['OFFSET_PAGE_LINK']='';
}
return $pageArray;
}
?>
print_r(getResultPages($resultCount,$resultLimit));
as you can see that just maps an array containing key+vals for each link to draw.
You'll need to modify teh SQL statement to use an $offset to start off the limit clause so you only get row x and greater from your result set returned.
LIMIT $offset,$however_many_rows_total