Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Get a users details for a diffrent person

0

49 views

Ok on my website it displays the users friends but it doesn't have their profile picture?

I have 2 databases. One is Users and that is were i save all the users details. the second database has if they are friends in it?

My question is how to get their profile pic from the users table .

p.s. the profile pic row is Proimg

this is my code

Tables

In the 2nd database i have the friends details id Sender Receiver Accepted 1 bob bill 1 2 fred bill 3

Accepted:

1 means that they havent accepted or declined 2 means that they have accepted 3 means that they have declined

In the 1st table i have the users details...

id Fullname Password proimg birthday 1 bill ** hi.jpg 1991-01-01 2 bob * hello.jpg 1991-07-02 3 fred *** hey.jpg 1991-10-05

<?php

$term = $fullname;
$sql12 = mysql_query("select * from Friends where Reciver like '%$term%' or Sender like '%$term%'"); 
$Friends = mysql_num_rows($sql12);

$t=1;
while($t<=$Friends)
  {
  while ($row = mysql_fetch_array($sql12))
    {
  If ($row['accepted'] == 2)
  {
  Echo '<img src="images/defaultprof.png" width="45px" height="45px"/>';   
  }
  else
{
$_SERVER['PHP_SELF'];
}
}
  $t++;
}  
?>

asked May 25, 2011 1:50 am CDT
posted via StackOverflow

1 Answer

3
 

You'd probably want to INNER JOIN the user data of the friends. This could be done like this: (based on made up tables ofcourse).

SELECT f.*, u.proImg FROM friends AS f 
INNER JOIN users AS u ON u.userID = f.friendID 
WHERE f.userID = 1;

Read entire JOIN syntax here.

answered May 25, 2011 2:23 am CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
MongoDB Query Details
January 19, 2011