This is the website that I am working on:
http://www.rezznor.com
The best way to explain my problem is if you see if for yourself. The first page brings up my blog. Under each post is a button to comment on it. The way I have it set up now is each post is coming from a database, the first field is the post ID number. You can see the ID number as the 2nd number after the Comment button (i.e. <button>0-16 would be the 16th post, or the ID number).
If you view the Source, you can see that the hidden field to be passed has a value of that number, but when you click on the button, the number that gets passed over is '4' (4 being the value of the post ID of the first post (the first 3 I deleted)).
Here is the code I have for the opening page:
<body>
<table width = 100%>
<?php
//connect to the database
//connect to the table
//assign the query string
$db = mysql_connect("localhost","rezznor","arcaus7");
mysql_select_db("rezznor_news" ,$db);
$sqlquery = mysql_query("SELECT * FROM June ORDER BY number DESC" ,$db);
//for every row in the database table, create the display block
while ($tablerows = mysql_fetch_row($sqlquery))
{
//assign the row count to a string variable
$postnumber = $tablerows[0];
//assign the comment count to a string variable
$commentcount = $tablerows[4];
//display the date and time
echo("<tr><td bgcolor = '#DADADA'>$tablerows[1] - $tablerows[2]</td></tr>");
//display the message
echo("<tr><td style = 'font-size:11px;'>$tablerows[3]</td></tr>");
//skip a line
echo("<tr><td><p></td></tr>");
//display the comment button in a form to pass the value of this post ID number to comment.php
echo("<tr><td bgcolor = black style = 'font-size:8px;'><font color = white>");
echo('<form action = "comment.php" method = "post">');
echo('<input type = "hidden" name = "pnumber" value = "');
echo $postnumber;
echo('">');
echo('<input type = "submit" name = "submit" value = "Comment this post:" style = "font: 10px">');
echo(' ');
//display the number of times this post has been commented on
echo $commentcount;
//trouble shooting purposes only, just to make sure that the postnumber is correct
//it will be erased when everything works fine
echo('-');
echo $postnumber;
//close the display block
echo('</font></td></tr>');
}
//after all rows of the database have been displayed, close the database connection
mysql_close();
?>
</table>
</body>
And here is the code for the next page:
<?php
$blah = $_POST['pnumber'];
echo ('bah');
echo ('<p>');
echo $blah;
echo ('<p>Working on it. Please be patient.</p>');
echo ('<form action = "comment2.php" method = "post">');
echo ('<fieldset><legend>Comment this post</legend>');
echo ('<p>');
echo ('<textarea name = "comment" rows = 10 cols = 60></textarea>');
echo ('<p>');
echo ('<div align = "center">');
echo ('<input type = "submit" name = "submit" value = "Submit" />');
echo ('<input type = "button" value = "Go Back" onclick = "history.go(-1)" />');
echo ('</div>');
echo ('</fieldset>');
echo ('</form>');
?>
Can anybody tell me why the value is correct, but when clicking the button is passes the value of the very first post, instead of the post that is supposed to be commented on?