Jump to content

Users friends status data for social application.


T-Vision

Recommended Posts

Hi Guys

 

http://www.phpfreaks.com/forums/Smileys/nrg_alpha/cool.gif

Cool

 

I have social networking application. I am trying to query a database to get the ids of all the users friends.  With the ids of all the users friends I am then trying to  query a second database with  the status feed  that contains all users status data.

 

 

 

I would like to echo the users friends status data only from the second database

 

 

 

code is below hope you can help.

 

 

 

Thank you.

 

 

 

<?Php

session_start();

?>

<?Php

//connect.

include("connect.php");

//Time ago coverting code.

include_once("classes/develop_php_library.php"); // Include the class library

 

 

 

$id=$_SESSION['id'];

 

 

 

/*find-out users friends*/

$findperson=mysql_query("SELECT * FROM friends WHERE sessid='$id'");

 

 

 

$timeAgoObject = new convertToAgo; // Create an object for the time conversion functions

 

 

 

$findfriend=mysql_num_rows($findperson);

 

 

 

//Count if the person has any friends. If they have friends get the ids of all their friends

if($findfriend>0)

{

while($rati=mysql_fetch_assoc($findperson))

{

    $fried=$rati['friendid'];

 

 

 

    //query the status table to give the users friends status.

 

 

 

    $mediafeeds=mysql_query("SELECT * FROM status WHERE userid='$fried' LIMIT 0,8");

 

 

 

    $media_num=mysql_num_rows($mediafeeds);

}

 

 

 

//count to see if their any status updates from users friends.

 

 

 

if($media_num>0)

{

 

 

 

//display all the users friends status data.

$datamedia="<TABLE BORDER='0' CELLPADDING=8 bgcolor='#FFFFFF' align='center' width='350px' height='30px'>";

 

 

 

while($mini=mysql_fetch_assoc($mediafeeds))

{

$user_id=$mini['userid'];

$viewer_nme=$mini['username'];

$viewer_picture=$mini['viewerpics'];

$media_pic=$mini['contentpic'];

$desc_ption=$mini['description'];

$date_time=$mini['date'];

 

 

 

$convertedTime = ($timeAgoObject -> convert_datetime($datetime)); // Convert Date Time

$datetime = ($timeAgoObject -> makeAgo($convertedTime)); // Then convert to ago time

 

..

 

//This is just a table with the data of all the users friends data.

 

 

$datamedia.="<tr><td valign='top' cellpadding='5' width='10%' bgcolor='#FFFFFF' align='center' >$viewer_nme<br/><a href='friendsprofile.php?uid=$uidd&&viewer=$id'><img src='".$mediapic."' width='80' height='80' align=left></td>

      <td valign='top' align='left' cellpadding='5' width='60%' bgcolor='#D3D3D3' cellpadding='0'>$introduction<br/>$titlenamed$titled<br/>$descd$desc_ ption<br/><br/>$datetime</td></tr>";

 

 

 

 

    }

$datamedia.="</TABLE>";

echo $datamedia;

}

else

{

echo "<font color='#333333' size='2' face='sans-serif' align=left><div align='center'> Your friends have not current activities.</div></font>";

}

}

 

else

 

{

 

 

 

 

 

}

Link to comment
Share on other sites

Well the question is I am finding it hard to query the second database with just the friendid variable from the first table. This is because the variable contain all the users friends ids as a single id. Making it hard to query the second database because friends id has become one number with all the users friends id.

 

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.