Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Linking Users
05-19-2011, 04:27 PM #1
- Join Date
- Feb 2011
- Thanked 0 Times in 0 Posts
Do you ever get that way were you keep thinking you know how to do it, then suddenly lose it? Well that's happening to me today, Im hoping somebody can help me.
On twitter, as many of you are probably aware, you can follow people and in return get followed by people. Thats similar with the site i have created, however, What i want to do is to build a list of all the "connections" made by a user on the profiles. (like a friends list)
Basically, connections meaning they follow somebody and that somebody is following them back.
Is this possible with PHP?
My follows table looks like this:
id / user_id / followed_user_id / timestamp
What i'm thinking so far: trying to grab the users that the profile_user is following but only the ones that are following back...
This is what i tried by no luck... ( i think im way off the mark )
$profile_user_id = $_REQUEST['id'];
$usersconnections = mysql_query("SELECT * FROM `follows` WHERE `user_id` = '$profile_user_id'");
$connections = mysql_fetch_array($usersconnections);
$findconnections = mysql_query("SELECT *
WHERE `followed_user_id` = '$profile_user_id'
AND `user_id` = '$connections[user_id]'
OR `user_id` = '$profile_user_id'
AND `followed_user_id` = '$connections[user_id]'
$connect = mysql_fetch_assoc($findconnections);
Last edited by brianjamesward; 05-19-2011 at 04:44 PM.
05-19-2011, 08:01 PM #2
- Join Date
- Dec 2005
- Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
- Thanked 637 Times in 625 Posts
Code:SELECT * FROM follows as f1 WHERE f1.user_id = $profile_user_id AND EXISTS ( SELECT 1 FROM follows as f2 WHERE f2.user_id = f1.followed_user_id)