View Full Version : Simple Forum

07-22-2008, 06:55 PM

I am making a simple forum for my website.

When viewing the thread you can leave comments, this all works fine. But i am trying to add the users details to each comment left.

$sql = "SELECT * FROM comment WHERE thread_id = $thread_id ORDER BY comment_id";
$result = mysql_query($sql, $conn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result)) {
$comment_id = $newArray['comment_id'];
$comment_comment = $newArray['comment_comment'];
$comment_date = $newArray['comment_date'];
$user_id = $newArray['user_id'];

How can i get the data from the members table?
I need to get user name and picture from the id given from the comments table?

echo "<table width='570' border='0'>
<td width='100' align='left' valign='top'<br><img src='http://www.mysite.com/$picture' width='80' height='80' /></td>
<td><p>$comment_comment </td>

Sorry to make it confusing.

07-22-2008, 08:41 PM
I have got this so far, but it is displaying the same picture for every user?

$sql = "SELECT comment.comment_id, comment.comment_comment, comment.comment_date, comment.user_name, comment.user_id, comment.comment_admin, MAX(members.picture ) FROM comment, members WHERE comment.thread_id = $thread_id GROUP BY comment.user_id";
$result = mysql_query($sql, $conn) or die(mysql_error());
while($row = mysql_fetch_row ($result))

I got the rest working, just want to sort out the photo