hey, im making a new thread for my previous question because i think i put in far to much code and was not making my question clear.
Ok, ive simplified it down to a simple simple table.
mmy problem is this.
I am designing a simple forum for my website. I have got it able to display all the topics and when you click a topic up appears a page with the post in it. the initial post. However wehn replies are made to the topic is where it goes wrong.
I want to include a bit of userinformation beside each reply (I.e username, postcount and a rating dependant on the amount of posts the user has made, i.e >50 newbie, 50-100 pro etc) thats where my problem starts.
I can get the PHP to display all the replies easily enough. Its when i issue a MySQL query to the userinfo table that it stops displaying all the replies and only displaying the first.
Here is the code which displays all the replies no problem. I understand it and it works well:
<?php
mysql_connect("localhost","root");
mysql_select_db(mountaincanon);
$query = "SELECT * FROM config";
$result = mysql_query($query);
$query = "SELECT * FROM forum_replies WHERE reply_to_PostID='$PostID'";
$result = mysql_query($query);
do {
if ($row[reply_to_PostID] != $PostID) {} else {
//Lets put the post into a nice friendly variable so we can use it after getting the user information
$POST_REPLY = "$row[post]";
$POSTED_BY = "$row[posted_by]";
//We first echo all the information about the poster
echo ("<hr>");
echo ("<table border=\"1\" width=\"100%\"><tr>\n");
//Now we have to get the post echoed
echo ("<td>$POST_REPLY");
echo ("</td></tr></table>\n");
}
} while ($row = mysql_fetch_array($result));
?>
Brilliant, but AS SOON as i issue the query to the user info table (i didnt bother eching the extra cell for the user info as the error is somewhere in the $query area) it all screws up?!?!
This si the code
<?php
mysql_connect("localhost","root");
mysql_select_db(mountaincanon);
$query = "SELECT * FROM config";
$result = mysql_query($query);
$query = "SELECT * FROM forum_replies WHERE reply_to_PostID='$PostID'";
$result = mysql_query($query);
do {
if ($row[reply_to_PostID] != $PostID) {} else {
//Lets put the post into a nice friendly variable so we can use it after getting the user information
$POST_REPLY = "$row[post]";
$POSTED_BY = "$row[posted_by]";
//We first echo all the information about the poster
echo ("<hr>");
echo ("<table border=\"1\" width=\"100%\"><tr>\n");
//now we select some userinformation
$query = "SELECT * FROM userinfo WHERE username='$POSTED_BY'";
$result= mysql_query($query);
//Now we have to get the post echoed
echo ("<td>$POST_REPLY");
echo ("</td></tr></table>\n");
}
} while ($row = mysql_fetch_array($result));
?>
Is it not possible to have a MySQL statement within a while or a do while loop??? is thats what wrong? if so how do i fix it? if not what am i doing wrong???
thanks!
Pablo de la Pena