抓住我关注的所有用户的帖子

时间:2014-06-29 01:49:25

标签: php while-loop posts

所以我建立了一个跟随系统,这显然是基于我的用户和#34;中存在的用户。表。我只是建立了一个帖子系统,用户可以发布内容。我正在尝试创建一个feed,其中用户(user1)从(user1)所关注的所有用户(user2,user3等)获取帖子。这就是我到目前为止所拥有的

//Query for the people that I am following
$getfollowing = mysqli_query($dbconx, "SELECT * FROM follows WHERE follower='$log_username'");
while($rowf = mysqli_fetch_array($getfollowing)){
    $following = $rowf['followed'];
    $follower = $rowf['follower'];
}
//Query for the post of the people that the logged in user is following
    $query = mysqli_query($dbconx, "SELECT * FROM posts WHERE username='$following' OR username='$log_username' ORDER BY posttime DESC");
    while($row = mysqli_fetch_array($query)){
        $user = strip_tags($row['username']);
        $title = strip_tags($row['posttitle']);
        $post = strip_tags($row['post']);
        $time = strip_tags($row['posttime']);

        $time = date('<font color="#C3C3C3">l F j, Y</font> | g:ia', strtotime($time));
        $query2 = mysqli_query($dbconx, "SELECT * FROM users WHERE username='$user'");
        $row2 = mysqli_fetch_array($query2);
        $fname = $row2['fullname'];
        $ava = $row2['avatar'];
        //User picture
        $pic = '<img src="user/'.$user.'/'.$ava.'" width="100" height="100" style="border: 1px solid #000;" alt="'.$user.'">';
        if($ava == NULL){
            $pic = '<img src="images/avatardefault.jpg" height="100" width="100" style="border: 1px solid #000;" alt="'.$user.'">';
        }

我可以收到我的帖子,只能收到我关注的其他用户的帖子。如何获取我关注的所有用户的所有帖子而不仅仅是其中一个?

0 个答案:

没有答案