[thelist] Prev & Next Links

Trev trev at trev.biz
Tue Jan 11 13:15:58 CST 2005


I wonder if someone can help me with a little problem?

I get so tired of silly little things stopping me doing what I need to
do, can anybody help me here?

I want prev and next links to show on my website, simple did it and it
works pretty well, problem is when I try to include a "|" charachter,
why you ask.

Well if I'm on page one I just want >> to display, if I'm on a page with
results either side of it I want the "|" as a nice little seperator, but
when I get to the last page I just want to display <<.

I hope you're with me by now ;) here's the code:

$maxshow = 9;
mysql_connect($server, $user, $pass) or die ("Can't connect!");
mysql_select_db($db) or die ("Can't open database!");

if(!$offset) $numrows = 0;
$result = mysql_query("SELECT * FROM $t4 LIMIT $offset, $maxshow");
$result2 = mysql_query("SELECT * FROM $t4");
$numrows = mysql_num_rows($result2);
$prev = $maxshow / $numrows;
$next = $maxshow + $offset;

if ($offset > $prev) {
   echo "<a href=" . $PHP_SELF . "?offset=" . ($offset - $maxshow) . "
class=\"ext\"><<</a> ";
}
if ($next < $numrows) {
   echo " | <a href=" . $PHP_SELF . "?offset=" . ($offset + $maxshow) .
" class=\"ext\">>></a>";
}

Is there any way to do it, cos I've tried it with else's and elseif's
even the really obvious stuff, it's driving me nuts, please somebody
save me before I shove my pc up it's own a$$...

Trev.



More information about the thelist mailing list