Link to home
Create AccountLog in
Avatar of pixelDepth
pixelDepth

asked on

Pagination

Hey guys,

I wondered if someone could give me a brief explanation on how to do pagination.  Now it's not the standard pagination i'm trying to do.  I can do...

1 2 3 4 5 6 7 8 9 10 etc

...But I would like to do this instead...

1 2 3 ... 11 12 13

Then if you click on page 3 it would turn to....

1 2 3 4 ... 11 12 13

etc.

Any help would be great.

Thanks :)
Avatar of AndyWHV
AndyWHV
Flag of Germany image

so you have to think about an algorithm what is happening there...

you want to count from page 1 to current page+1

so its
for ($nr=1; $nr <= $curpage+1; $nr++) {
   echo $nr."&nbsp;";
}
echo ("...");
$nr = $lastpage-3;
while ($nr <= $lastpage) {
   echo $nr."&nbsp;";
}

assuming you have $lastpage with the last page nummber and
$curpage with the current page number
ASKER CERTIFIED SOLUTION
Avatar of AndyWHV
AndyWHV
Flag of Germany image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Avatar of Marcus Bointon
Marcus Bointon
Flag of France image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of pixelDepth
pixelDepth

ASKER

Thanks Guys

I managed to write my own class in the end to do it :D