I've a pagination script and it is working fine. I want to add a range to my pagination. BUt it should be in the following format;
<< < 1 | 2 | 3 | 4 | 5 > >>
When I click on "5", then it should be;
<< < 4 | 5 | 6 | 7 | 8 > >>
Similarly when click on "8", then it should be;
<< < 7 | 8 | 9 | 10 | 11 > >>
Suppose "11" is the last page and if we click on 11, it should be;
<< < 7 | 8 | 9 | 10 | 11 > >>
My code is look like this;
$recordLimit = 4;
$totalNumberofRecords = 100;
$currentpage = !empty( $startPage ) ? (int) $startPage : 1 ;
$startFrom = ( $currentpage -1 ) * $recordLimit;
$limit = $startFrom.','.$recordLimit;
$totalPages = ceil( $totalNumberOfRecords / $recordLimit );
$j = 0;
for ($i = max(1, $currentpage - 1); $i<= min($currentpage + 4, $totalPages); $i++) {
$fairLists['pages'][$j] = $i;
if ( $startPage == $fairLists['pages'][$j] || ( $j == 0 && empty( $startPage ) )
{
$fairLists['pages'][$j] = array( $i ,"font-weight:bold;");
}else{
$fairLists['pages'][$j] = array( $i , 'font-weight:normal;' );
}
$j++;
}
I want to limit the range to 5, and when we reach the range, it should display 1 previous record and 3 next records;
If somebody knows the script, then please help me,
Thanks,
Arun