开发者

how to show friend list in home page,using php my sql?

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开发者_Go百科 the table named profile.


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.)


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

you must post some more details!


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>';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜