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

Recommended Answers

All 3 Replies

show us your mysql ordering code.

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;
        }}}

try ordering by timestamp instead of id.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.