Re: counting pages...

From: Date: Tue, 27 Apr 2004 14:24:39 +0000
Subject: Re: counting pages...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-184761@lists.php.net to get a copy of this message
Perfect! Cheers for that... Anther trick for the code archive! "John W. Holmes" <holmes072000@charter.net> 27/04/2004 13:49 Please respond to "John W. Holmes" <holmes072000@charter.net> To <Tristan.Pretty@risk.sungard.com>, <php-general@lists.php.net> cc Subject Re: [PHP] counting pages... From: <Tristan.Pretty@risk.sungard.com> > I want to convert my page counter to display just a limited No of page > options... > Currently, after my database request, I'm getting 1000's of pages... > I want to do something like: > > < < Previous -21 22 23 24 25 26+ Next > > > > Anyhoo, here's my current code... > ================================= > > if($page > 1){ > $prev = ($page - 1); > $start_pick = "<a > href=\"".$_SERVER['PHP_SELF']."?page=$prev\">< < > Previous</a>&nbsp;"; > } else { > $start_pick = "< < Previous&nbsp;"; > } > > for($i = 1; $i <= $total_pages; $i++){ So, you know you're on $page and you want to go from $page-10 to $page+10, right? $startpage = max(1,$page-10); $endpage = min($page+10,$total_pages); for($i=$startpage; $i <= $endpage; $i++) { and then carry on with the rest of your code. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ********************************************************************* The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. ***********************************************************************

« previous php.general (#184761) next »