Anyway, I have a MySQL database called "forum", with three tables; "comment", "thread", and "user". I had the idea of creating a new field in the "comment" table called "reply-to_x " (each comment posted has a specific ID, and x being the comment that it replies to). But I have no idea how I would get PHP to know to place reply comments under the comments they reply to. Here is the code in showThread.php that looks through the database for comments:
Expand|Select|Wrap|Line Numbers
- <?php
- mysql_connect('localhost','root','fakepass') or die(mysql_error());
- mysql_select_db('forum') or die(mysql_error());
- $result = mysql_query('SELECT * FROM comment WHERE thread_id='.$t);
- while($row = mysql_fetch_array( $result )) {
- echo '<div class="comment" id="'.$row['id'].'">'."\n";
- echo '<p class="handle">'.$row['name'].'</a></p>'."\n";
- echo '<p>'.$row['message'].'</p>'."\n";
- echo '</div>'."\n";
- }
- mysql_close('forum');
- ?>
Any ideas on how to make reply-tos possible?
Thanks,
Steven