Results 1 to 3 of 3
Mar 31, 2007, 13:21 #1
- Join Date
- Sep 2005
- 0 Post(s)
- 0 Thread(s)
Creating a Submit Button to pull next 50 records
(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!!!!!
$num = 0;
$total_num = ($num + $sent_num);
$link = mysql_connect(connectinfo is here ...)
or die('Could not connect: ' . mysql_error());
$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>';
while ($row = mysql_fetch_assoc($result))
/* 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">