Jump to content

PHP / SQL Question


Recommended Posts

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 post
Share on other sites

Do the tables share a data connection (do they relate to each other)? If so, how?

Link to post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites
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 post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...