Ok i have a site that has a member system and users are able to leave comments on news posts and such if logged in.
What I am trying to do is display the user’s avatar next to each of their comments based on poster ID.
When a user posts a comment i pull different info from their account/site such as userid, username, newsid and store it in a table called “comments” along with the comment text.
This is part of my code for displaying comments, I want to display the posters avatar based on $row[‘posterid’] for each comment. The problem is posterid is stored in a table called “comments” and the users avatar is stored in a table called “users”. There is no way to do something like this is there?
[php]
<?php $ava = mysql_query("SELECT * FROM `users` WHERE user_id='".mysql_escape_string($row['poserid'])."'") or die(mysql_error()); $avatar=mysql_fetch_assoc($ava); echo ''.$avatar['user_avatar'].''; ?>[/php]
Display Comments:
[php]
Post #'.$row['com_id'].' by '.$row['user_name'].' on '.$row['date'].' |
---|
'.nl2br($row['comment_text']).' |
|
'; } ?>
[/php]