Jump to content

Display content from friends and myself (Important)


Fricti0n

Recommended Posts

Hi, I need some help on a MySQL query that should select Status Updates from the friends in the friends list and from the logged in user.

 

This is the code I came up with, the $now_showing is the number of Status Updates to show on execute, the value is 10

// This query counts how many friends the logged in user have
$q_count_friends = mysql_query("SELECT * FROM friends WHERE member_id = '".$_SESSION['userid']."'");
$r_count_friends = mysql_num_rows($q_count_friends);
if($r_count_friends == 0) {
        // If the logged in user don't have any friends, this query will be executed, this query is working very well, exactly as I want it to be
$q_resolve_member_status = mysql_query("SELECT DISTINCT * FROM status_updates WHERE member_id = '".$_SESSION['userid']."' ORDER BY status_id DESC LIMIT 0,$now_showing");
} else {
        // If the logged in user have one or more friends, this query will be executed, and this is where I have a problem -.-.
        // It works in a way, but the entries is being duplicated, and the name of the Status owner is messed up, the query picks a random name from the members table...
$q_resolve_member_status = mysql_query("SELECT DISTINCT * FROM status_updates JOIN friends ON status_updates.member_id = friends.friend_with LEFT JOIN members ON status_updates.member_id = members.member_id ORDER BY status_id DESC LIMIT 0,$now_showing");
}
while($r_resolve_member_status = mysql_fetch_array($q_resolve_member_status)) {
        // While loop
}

 

Please help me with this query :)

$q_resolve_member_status = mysql_query("SELECT DISTINCT * FROM status_updates JOIN friends ON status_updates.member_id = friends.friend_with LEFT JOIN members ON status_updates.member_id = members.member_id ORDER BY status_id DESC LIMIT 0,$now_showing");

 

Thankful for any help I can get! :D

 

- Fricti0n

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.