Re[2]: [PHP] Re: counting pages...

From: Date: Tue, 27 Apr 2004 11:48:39 +0000
Subject: Re[2]: [PHP] Re: counting pages...
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-184751@lists.php.net to get a copy of this message
Hello Tristan, Tuesday, April 27, 2004, 12:32:49 PM, you wrote: TPrsc> These only appear to do what I've got already... TPrsc> I don't want to have 1000's of page number on my page. TPrsc> I simply want to have say 5 pages either side of my current page TPrsc> displayed. Get the total number of pages possible (i.e. count them), call it total_pages or something. Now define the start_page (usually page 1, right?). Then you've got current_page - the one you're on. I would do this: If total_pages less than 10, just display links for 1 to 10 highlighting the current page, using a simple for loop. Otherwise: Take current_page and minus 5, count how many pages "back" you can go before you hit start_page (if at all). Do the same with current_page + 5, count how many pages until you've either added 5 pages or hit total_pages. Then just draw them all out. I know it's not actual code, but you should get the idea. -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html

« previous php.general (#184751) next »