Usarjjaco Posted March 17, 2012 Share Posted March 17, 2012 Hello Everyone, Been awhile since I've meandered into the PHP forums on here, but I'm banging my head against a wall trying to figure this one out. Set Up: I have 2 tables in a SQL database. One lists whether a person is a friend with another person. The second is an Activity table that lists what someone posts as a status update. Goal: I need to be able to display not only a users own status updates, but updates that any of their "friends" have posted. Right now I've only been able to pull the persons own feed with a simple query, and I'm wondering how I would go about pulling all feeds from anyone that they are friends with. Friends Table has the following fields: id, senderid, recipientid, status (Status can be 'N' for declined, 'Y' for accepted, and 'P' for pending, for the purposes of this problem, I only need to pull the friends with 'Y') The Activity table has: id, activity, posterid, recipientid. Thanks in advance guys, and if there's any more information I can get to you to get a hand with this just let me know! Link to comment Share on other sites More sharing options...
niche Posted March 17, 2012 Share Posted March 17, 2012 Do the tables share a data connection (do they relate to each other)? If so, how? Link to comment Share on other sites More sharing options...
Usarjjaco Posted March 18, 2012 Author Share Posted March 18, 2012 Niche, Both tables are in the same database, just different tables. Basically the "Activity" table will list all actions a user performs, and all the times they post on their own page or someone elses (similar to social networking), the "Friends" table lists the USER ID's of the sender and receiver, as well as if the friendship is active. I'm looking for a way that the Active friendsships will be able to see eachother's activity on their own home page. There is a third table which holds all the users and their personal data, so I'm just looking at how I pull information from Activity based on the "friendships" in the friend table. Link to comment Share on other sites More sharing options...
davej Posted March 18, 2012 Share Posted March 18, 2012 Friends Table: id, senderid, recipientid, status (Status can be 'N' for declined, 'Y' for accepted) Activity table: id, activity, posterid, recipientid This question should probably be posted in the SQL forum. Can you show us the CREATE TABLE statements you used? Link to comment Share on other sites More sharing options...
Usarjjaco Posted March 19, 2012 Author Share Posted March 19, 2012 I'll throw up a post in the SQL forums, I am using PHPmyAdmin for the Table creation, so I don't have the SQL verbage in front of me. Link to comment Share on other sites More sharing options...
astralaaron Posted March 20, 2012 Share Posted March 20, 2012 like davej is pointing out you should make a table to hold the friendships, both people's id in the same table row shows their connection, and the status is whether or not the friendship is pending Link to comment Share on other sites More sharing options...
thescientist Posted March 21, 2012 Share Posted March 21, 2012 I'll throw up a post in the SQL forums, I am using PHPmyAdmin for the Table creation, so I don't have the SQL verbage in front of me.phpMyAdmin typically display the SQL output of whatever actions you make it execute after its done it. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.