Re: how to get rid of that annoying |
| From: | Nitsan Bin-Nun | Date: | Mon, 08 Jun 2009 19:06:15 +0000 |
| Subject: | Re: how to get rid of that annoying | | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-293760@lists.php.net to get a copy of this message | ||
Your code is worse than spaghetti..... (and spaghetti usually looks good..)
I would suggest you to wire it up again even befores figuring out the
appended | in it ;)
--
Nitsan
On Mon, Jun 8, 2009 at 8:56 PM, PJ <af.gourmet@videotron.ca> wrote:
> I know this a silly question, but I can't figure out if it's even
> possible to get rid of that final annoying | in my pagination script.
>
> <?echo "<p>Navigation</p>";
>
> echo (($page !=1)?"<a href='".build_url("books.php",
> "page",
> 1)."'>first</a>":"first")." ... ";
> echo (($page>1)?"<a href='".build_url("books.php",
> "page",
> $page-1)."'>prev</a>":"prev")." | ";
> for($i=$page; $i<=($page+$records_per_page-2)+1; $i++){
> if ($i!=$page && $i<ceil($count/$records_per_page))
> echo "<a href='".build_url("books.php", "page",
> $i)."'>$i</a>", " | ";
> elseif ($i>ceil($count/$records_per_page))
> continue;
> else echo $i, " | ";
> }
> echo " | ... ".(($page<$count)?"<a
> href='".build_url("books.php",
> "page", $page+1)."'>next</a>":"next");
> echo " ... ".(($page<$count)?"<a
> href='".build_url("books.php", "page",
> ceil($count/$records_per_page))."'>last</a>":"last");
> //echo "<p>Table Order</p>";
> echo "<br />Ordered alphabetically by book title : ";
> echo $dir=="ASC"?"Ascending":"<a
> href='".build_url("books.php", "dir",
> "asc")."'>Ascending</a>";
> echo " | ";
> echo $dir=="DESC"?"Descending":"<a
> href='".build_url("books.php", "dir",
> "desc")."'>Descending</a>";
> echo "<br />";?>
>
> This produces a very nifty pagination - the problem is how to get rid of
> the final pages that show up as greater than what is available. The
> script above works fine, except it leaves that final | ...
> Any simple solutions?
>
> --
> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> -------------------------------------------------------------
> Phil Jourdan --- pj@ptahhotep.com
> http://www.ptahhotep.com
> http://www.chiccantine.com/andypantry.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>