Forum Moderators: coopster
$query = "SELECT count(*) as count FROM user_char";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start > 0)
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 50) ."\">Previous</a><BR>\n";
if($numrows > ($start + 50))
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 50) ."\">Next</a><BR>\n";
echo '</table></center>';
/*End beginning table for inner cell*/
echo '</td></tr></table>';
but say it starts at 34, if the user presses back it will display nothing because $start = -16.
I would like it to stop at 0 but am not sure how to do this.
Somewhere in your code, you need the equivalent of:
if ($start < 0) start = 0; (or possibly)
if ($start < 1) start = 1;
This and similar limits should be imposed after incrementing or
decrementing, and BEFORE showing or echoing your buttons.
You may want to impose an upper limit as well so people don't
sail off to some non-existent page. - Larry
$query = "SELECT count(*) as count FROM user_char";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if ($start < 0)
{
$start = 1;
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start) ."\">Previous</a><BR>\n";
}
elseif($start > 0)
{
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 50) ."\">Previous</a><BR>\n";
}
if($numrows > ($start + 50))
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 50) ."\">Next</a><BR>\n";
echo '</table></center>';
/*End beginning table for inner cell*/
echo '</td></tr></table>';
But it still is not working I do not know why.
Anyone have any ideas?