I have an a users friends stored in the database as friends_array. They store the id of the friends and are separated with coma’s.
I was able to output the posts made by the users but i have a problem. This is my code.
if ($friend_feed != "") {
$feed= explode(',', $feed);
foreach ($feedas $key => $value) {
$query = mysql_query("SELECT * FROM `users` WHERE user_id=$value ORDER BY `time` DESC") or die ("Please try again later.");
while ($row = mysql_fetch_array($query)) {
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$username = $row['username'];
$post = $row['post'];
echo '<hr><a href ="'. $username .'">'.$first_name.' '.$last_name.'</a> <br>'.$post;
}
}
}
This code above goes through the friend id’s and outputs the posts…but it goes by each friend first…
For example i have 3 friends with the id’s 70,71 and 72. If all of them make 2 posts each, they are outputted in the order of their id stored in the database, so user 70’s posts will come first and then all of user 71’s and then user 72…
How do i stop this and output by what post is recently put into the database?
You can try a different query, like:
and drop the whole
foreachandexplode