PJ wrote:
Robert Cummings wrote:
PJ 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))
  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",
//echo "<p>Table Order</p>";
echo "<br />Ordered alphabetically by book title : ";
echo $dir=="ASC"?"Ascending":"<a href='".build_url("books.php", "dir",
echo " | ";
echo $dir=="DESC"?"Descending":"<a href='".build_url("books.php", "dir",
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?

Do it differently... build an array of the appropriate entries. When
done, use implode( ' | ', $yourArray ).

Hate to disappoint you all, but I finally found the errant | .
Ridiculous, really, that I bothered you all.
it's in the line indicated above --- echo " | ... " --- lose the | and
it all works like a charm.

:-)     ;-)

You didn't disappoint me... I've seen code like that before, I just thought you'd benefit from a cleaner approach instead of the above mess.

Application and Templating Framework for PHP

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to