Hey all.  Im trying to setup a page where it has prev/next links.  I 
have included a snip of the code.  On the first page everything is cool, 
but on subsequent pages, the count get out of control.  I was testing 
with displaying 5 entries at a time.  The first page is good, the next 
displays 7 and so on.  If you see anything in there, please let me know, 
its probably crude to what others are using but I wanted to give it a 
shot instead of coping someone elses work.
Thanks
$max_row = 5;
if ($op == "next") {
        $low = $low + $max_row;
        $high = $low + $max_row;
        $result = mysql_query("SELECT * FROM TABLENAME where Post='yes' LIMIT $low, 
$high");
                while($row = mysql_fetch_row($result)) {
                        echo "<b>$row[1] writes</b>:<br>\n";
                        echo "&nbsp &nbsp <i>$row[2]</i><br>\n";
                        echo "<b>AskLee writes</b>:<br>\n";
                        echo "&nbsp &nbsp <i>$row[3]</i><br>\n";
                        echo "<hr>\n";
                 }
}
elseif ($op == "prev") {
        $low = $low - $max_row;
        $high = $high - $max_row;
        $result = mysql_query("SELECT * FROM TABLENAME where Post='yes' LIMIT $low, 
$high");
                while($row = mysql_fetch_row($result)) {
                        echo "<b>$row[1] writes</b>:<br>\n";
                        echo "&nbsp &nbsp <i>$row[2]</i><br>\n";
                        echo "<b>AskLee writes</b>:<br>\n";
                        echo "&nbsp &nbsp <i>$row[3]</i><br>\n";
                        echo "<hr>\n";
                 }
} else {
        $low = 0;
        $high = $low + $max_row;
        $result = mysql_query("SELECT * FROM TABLENAME where Post='yes' LIMIT $low, 
$high");
        while($row = mysql_fetch_row($result)) {
                echo "<b>$row[1] writes</b>:<br>\n";
                echo "&nbsp &nbsp <i>$row[2]</i><br>\n";
                echo "<b>AskLee writes</b>:<br>\n";
                echo "&nbsp &nbsp <i>$row[3]</i><br>\n";
                echo "<hr>\n";
                                        }
}
$result = mysql_query("SELECT * FROM mpn_asklee where Post='yes'");
$num_rows = mysql_num_rows($result);
if ($num_rows > $max_row) {
        echo "<table width=\"100%\" cellspacing=\"0\" border=\"0\" 
cellpadding=\"0\">\n";
        echo "<tr><td align =\"left\">\n";
        if ($low > $max_row) {
                echo "<a href=\"$PHP_SELF?op=prev&low=$low&high=$high\">Previous</a>";
                                }
        echo "</td><td align =\"right\">\n";
        if ($num_rows > $high) {
                echo "<a href=\"$PHP_SELF?op=next&low=$low&high=$high\">Next</a>";
                echo "</td></tr></table>\n"
                }
}
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to