0

The user_id can be found on the replies table but also in the profiles table. The profiles table has the real_name column.

Below I get all the replies for a specific article_id. My question is how do I echo the real_name of the commenters that is saved into the profiles table ?

I am consider the performance of this.

$replies = mysql_query("select * from replies where article_id = '$row[id]' order by timestamp desc");

while($reply = mysql_fetch_assoc($replies)) {

I can echo the comments from the replies table, but how do I echo the real_name of each?

}
2
  • Join the profiles table? Something like select p.real_name, r.* from replies as r join profiles as p on r.profileid = p.profileid where article_id = '$row[id]' order by timestamp desc might have to update theprofileid column names Commented Apr 4, 2015 at 15:53
  • Also have a look at either mysqli or PDO as mysql_ functions were deprecated as of PHP 5.5.0 Commented Apr 4, 2015 at 16:24

1 Answer 1

1

Try That :

$replies = mysql_query("select * from replies,profiles where article_id = '$row[id]' AND replies.user_id=profiles.id order by timestamp desc");

Good luck !

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.