mrcniceguy 5 Posting Whiz in Training

Guys i`m trying to archive something like facebook,twitter wall Display.
I have a friend table,inside it has id,friendid and userid.
also got feeds table which contains id,action,sender_id,statusid,status,date.
What i have succeeded to do is if You are logged in you can see all the updates from your friends...As the code below Shows.
Now i want in the same sql script to be able to view the updates made by me(OWN UPDATES,like status,added a friend and so so) including friends.

$logged_id=$_SESSION['id'];//logged in User
include"config.php";//db connection
/****display feeds,wall*********/
$query="SELECT
 feeds.id
,feeds.action
,feeds.sender_id
,feeds.friend
,feeds.statusid
,feeds.status
,feeds.date
FROM friends 
INNER JOIN feeds
ON friends.friendid=feeds.sender_id
WHERE (friends.userid='$logged_id')ORDER BY id DESC LIMIT 30";
$result=mysql_query($query);
$countfeed=mysql_num_rows($result);
if($countfeed>0){
while($row=mysql_fetch_array($result))
 {
  $updateid=$row['id'];
  $senderupdate=$row['sender_id'];
  $friend=$row['friend'];
  $status=$row['status'];
  $statusid=$row['statusid'];
  //$action=$row['action'];
   //query the name of the update sender
    $changeid=mysql_fetch_array(mysql_query("SELECT names FROM profile WHERE  id='$senderupdate'"));
  $hisname=$roo['names'];
   

  if($statusid){  //check if wall status

    echo"$hisname updated his wall $status<br/>";

  }elseif($friend){
    //select the name of the friend
     echo"$hisname   added $friend as a friend<br/>";
  
  }




 }

}else{
echo"THERE ARE NO FRIENDS UPDATE<br/>";
echo"Add more friends to receive their updates";
}

I KNOW ITS SOMETHING TO DO WITH SQL,BUT I HAVE TRIED WITH NO SUCCESS.

I WILL BE GRATEFULL IF SOMEONE WILL HELP ME IN THIS PROBLEM.

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.