So i have my pagination links like this.
for ( $counter = 0; $counter <= $page_amount; $counter += 1) {
echo "<a href=\"section.php?q=$section&p=$counter\">";
echo $counter+1;
echo "</a>";
}
And the links grows like:
1 2 3 4 5 6 7 and so on.
But i want to limit this so if there is more than 7 pages it shall only show 7 links like this:
1 2 3 ... 10 11 12
where 12 is the last page.
And if you go to next page it will only change the first pages like this:
3 4 5 ... 10 11 12
until you reach the last 7 pages like this:
6 7 8 9 10 11 12
How do i do this ??
please help.