0

I want something like how facebooks wall works but when i call what others have posted its out of order with time

for example:

First Table (Users):
UserID: 1, Name: Matt,
UserID: 2, Name: Bob,
UserID: 3, Name: Steve,

Second Table (Friends):
UserID: 1, FriendUserId: 2
UserID: 1, FriendUserId: 3,

Third Table (Post):
PostId: 1, UserId: 2, Time: 1:00,
PostId: 2, UserId: 3, Time: 2:00,
PostId: 3, UserId: 2, Time: 3:00,
PostId: 4, UserId: 3, Time: 4:00,

I want it to echo out in order of time but it echos out as all posts from one person first in order of time then goes on to the next user as shown:

It echos like this:
Post 1
Post 3
Post 2
Post 4

But i want:
Post 1
Post 2
Post 3
Post 4

any ideas on how to to this?
thanks

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by ApocDen
0

Here ya go

$id=$_SESSION['identidy'];

$query_friends=mysql_query("SELECT friend_id FROM friends WHERE user_id='$id' AND is_friend='1' ORDER BY friend_id DESC");

	$rows=mysql_num_rows($query_friends);
	$times=time();

	if($rows==0){
	echo "You are currently not friends to anyone";
	}
	else{
	while($row1=mysql_fetch_assoc($query_friends)){
	$friend_id=$row1['user_id'];

	$getposts=mysql_query("SELECT * FROM status WHERE id_user='$friend_id' AND $times-timestamp<604800 ORDER BY id DESC");

	while($row= mysql_fetch_assoc($getposts))
	{
	$ids = $row['id'];
	$id_user=$row['id_user'];
        $status=$row['status'];
        $time=$row['time'];        

        echo $id;
        echo $id_user;
        echo $status;
        echo $time;
        }}}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.