(I originally posted this in the mySQL forum but was told to move it over here ...)

This is my first time getting data out of a database and I am a little over my head.
I am extracting 3 fields (id -which is autoincrement primary key, nick & message) and displaying the first 50 records. Where I am stumped is if there are more records I would like to add a submit button where it sends a variable $sent_num (which is the total number of records displayed on this page plus 50) back to the page so that the user sees the next 50 records if they are available. I have commented where I think the code should go, my problem is I am too green to figure out what the best way to do this would be. Any help is appreciated!!!!!

PHP Code:
$sent_num=$_POST['sent_num'];

$num 0;
$total_num = ($num $sent_num);
$link mysql_connect(connectinfo is here ...)
   or die(
'Could not connect: ' mysql_error());
   echo 
'';
mysql_select_db('wizzoband'$link);

$result mysql_query("SELECT * FROM petition WHERE id > ($total_num) AND id < ($total_num + 50) ORDER BY id"$link);

echo 
'<table border=0><tr><td>';
echo 
'<tr><th>#</th><th>Nickname</th><th>Message</th></tr>';

while (
$row mysql_fetch_assoc($result)) 
{

echo
'<tr><td>';
echo 
htmlspecialchars(stripslashes($row['id']));
echo
'</td><td>';
echo 
htmlspecialchars(stripslashes($row['nick']));
echo
'</td><td>';
echo 
htmlspecialchars(stripslashes($row['message']));
echo
'</td></tr>';
}

echo 
'</table>';
/* need some sort of conditional that says if the total number of rows is greater than the highest id on this page then there is the following option;
The rest of my (non commented) code works at this point.

echo '<form name="next" method="post" action="form.php"><input name="sent_num" type="hidden" value="('.$total_num +50).'"><input name="submit" type="submit" value="Get next 50 signatures">
</form>';
*/