tags:

views:

69

answers:

3

if an user login in his/her home page then he needs to see his friennds, i hane one table name
frienddetails containing userid and friendid,and another table name profile containg userid,name.now how can i show user's friend in the home page? the friend details need to show in user home page,but that is in the table named profile.

A: 

make query to mysql with id of user, get friends in a loop, print on page

you must post some more details!

Dobiatowski
+1  A: 

1) u need to write code inside the homepage (if it's index.php)

2) fire a sql query SELECT * FROM frienddetails, users WHERE users.userid = frienddetails .userid AND users.userid = {current user ID}

(noob question.)

Ankit Jain
A: 

PHP & MySQL

// select all friends of [THE_CURRENT_USER_ID]
$sql = mysql_query("
SELECT profile_userid, profile_name, profile_image 
  FROM fsb_friendlist
LEFT JOIN fsb_profile ON (friendlist_friendid=profile_userid) 
WHERE friendlist_memberid = THE_CURRENT_USER_ID"); // change here!

// print all the found members' name and image
while ($t = mysql_fetch_assoc($sql)) {
  echo "<div style='width:150px; float:left;'>"
  echo "<strong>$t[profile_name]</strong><br />";
  echo "<img src='$t[profile_image]' alt='' />";
  echo "</div>"
}

// end the list
echo '<div style="clear:both;"></div>';
galambalazs