SEARCH

The How-To Geek Forums Have Migrated to Discourse

How-To Geek Forums / Geek Stuff

any PHP geeks out there?

(3 posts)
  • Started 5 years ago by pipo
  • Latest reply from pipo
  • Topic Viewed 1164 times

pipo
pipo
Posts: 428

i'm a little rusty with my PHP and i've been trying to make this mini project, my prob is with the paging, i'm trying not to display all the page numbers when there's a lot of pages
ie. if i have 10 pages, what i'm displaying is "1 2 3 4 5 6 7 8 9 10" but what i want to do is displaying something like "1 2 3 .... 8 9 10"

can anybody point me to a site that discusses that, i'm not really sure what keywords to type in google (i tried - php paging display "..." in page numbers multiple pages)

Posted 5 years ago
Top
 
wallaceb
wallaceb
Posts: 214

i have written code that does that

basically in a nut shell, you say how many actual pages links you want

1 | 2 |3|......|8 |9|10

in the example above you want only 6 links to display
you use a for loop or some kind of loop that works well for you that does the first three links, when it knows it has done those three, then it will skip to $total_page_links -3;

and then it will continue the loop

$total_links = 10;
for ($x=0; $x<3; $x++)
{
print "=$x";
}//end for loop

print "....";

for for ($x=$total_links-3; $x<$total_links; $x++)
{
print "=$x";
}//end for loop

this is something i just quickly wrote up, is not complete, and probably wont work as is, but it should give you an idea.

Posted 5 years ago
Top
 
pipo
pipo
Posts: 428

so what i do is have 2 loops, one that displays the start of the pages (1 | 2 | 3) and another to display the last 3 pages (8 | 9 | 10), that's clever, hehe.

thanks wallaceb, i'm gonna work on that and try to see how to fit the [Last page] [Prev] [Next] [First page] in.

Posted 5 years ago
Top
 



Topic Closed

This topic has been closed to new replies.

Enter Your Email Here to Get Access for Free:

Go check your email!