I have a custom forum i'm making... And I have a section of code that (should) display all the posts in that thread... The code works, but only for the first post... It doesn't add the second/third (etc...) posts... Can anyone find the problem with this code? $query = ("SELECT * FROM `Forum3` WHERE `ThreadId` = '$id'"); $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $username = $row['Username']; $post = $row['Post']; $query = ("SELECT * FROM `Zombie` WHERE `Username` = '$username'"); $result = mysql_query($query); $row = mysql_fetch_array($result); echo "<a href= 'username.php?" . "&id=". urlencode($row['Id']) . "'>". $row['Username'] ."</a>". ": ". $post; echo "<br>"; } Thanks alot, James
You're overwriting the $row and $result variables with the second query. Rename them to something else and it should work.
I take it each post in your table has the user id, so you need just one query SELECT * FROM `forum_post_table`, `user_table` WHERE `forum_post_table`.`user_key` = `user_table`.`user_key` AND `forum_post_table`.`thread_unique_key` = 'thread id here' Something along those lines should do it. Replace the tables and columns with your ones and you should be fine