Turning user ID into name (seperate tables) in PHP

Posted by mobile on Stack Overflow See other posts from Stack Overflow or by mobile
Published on 2012-10-14T21:32:36Z Indexed on 2012/10/14 21:36 UTC
Read the original article Hit count: 142

Filed under:
|

I am currently trying to display the username of people who i am following, the problem is that during the following process, only the ID of me and the person i'm following is stored.

I've got it to the point where the ID's are displayed but i'd like to show the names hyperlinked. $p_id is the profile ID.

Here's what I've got:

$following = mysql_query("SELECT `follower`, `followed` FROM user_follow WHERE follower=$p_id");

I am following: <?php while($apple = mysql_fetch_array($following)){

            echo '<a href="'.$apple['followed'].'">+'.$apple['followed'].'</a> ';
            }?>

The usernames are in a different table "users" under the field "username" - I need them to match up with the ID's that are currently displayed, and be displayed.

Any help appreciated,

thanks guys

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql