Subscribe to How-To Geek

Welcome to the How-To Geek Forums

We encourage you to register on our forums and post any questions you might have. The How-To Geeks monitor this forum and will respond to your question quickly.

How-To Geek Forums » Geek Stuff

any PHP geeks out there?

(3 posts)
  • Started 3 months ago by pipo
  • Latest reply from pipo
  • Topic Viewed 130 times


pipo
pipo
Posts: 424

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 3 months ago #
 
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 3 months ago #
 
pipo
pipo
Posts: 424

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 3 months ago #
 

RSS feed for this topic

Reply

You must log in to post.

Sponsored Links
Getting Started
About How-To Geek
What Is That Process?
svchost.exe
jusched.exe
dwm.exe
ctfmon.exe
wmpnetwk.exe
wmpnscfg.exe
rundll32.exe
wfcrun32.exe
Ipoint.exe
Itype.exe
Wfica32.exe
Mobsync.exe
Cmd.exe
Dpupdchk.exe Adobe_Updater.exe

Copyright © 2006-2008 HowToGeek.com. All Rights Reserved.