I have a pagination script that displays a list of all pages like so:
prev [1][2][3][4][5][6][7][8][9][10][11][12][13][14] next
But I would like to only
$page = 3;
$totalPages = 33;
$count = 9;
$startPage = max(1, $page - $count);
$endPage = min( $totalPages, $page + $count);
if($page-1 > 0){
echo '<< Prev';
}
for($i = $startPage; $i < $endPage; $i++): if($i <= $totalPages):
echo '"style="margin-right:2px;" href="/search-
results?page="'.$i.'">'.$i.'';
endif; endfor;
if($page < $totalPages){
echo 'Next >>';
}