我有两个名为'帖子'和'朋友'的表。我想要显示 我的代码 -
$yyss = mysql_query("select * from friends where friend_id='$emaild' or user_id='$emaild'");
$rp = mysql_num_rows($yyss);
$fk = mysql_query("select * from friends where friend_id='$emaild' or user_id='$emaild' limit 3");
while($nr = mysql_fetch_assoc($fk)){
$frid=$nr['user_id'];
$ffr = $nr['friend_id'];
$sql = mysql_query("SELECT * FROM posts where id='$frid' or id='$ffr' order by unid desc");
}
如何显示用户朋友发布的帖子而不是一次又一次地显示这些帖子?
答案 0 :(得分:1)
$friends = mysql_query("SELECT * FROM friends WHERE friend1 = '$my_uid'");
while($friend = mysql_fetch_assoc($friends)){
$f[] = $friend['friend2'];
}
$posts = mysql_query("SELECT * FROM posts WHERE owner_id IN
(".implode(",", $f).")");