JonnySnip3r Posted August 23, 2010 Share Posted August 23, 2010 Hey guys i have been making a site that allows people to make friends and make posts on each walls a majority is done now but when i came to do the posting on walls i have hit one cause i cant figure out the query i will need for such a pretty complex task. It works like this i have a friends table and a topics table each something like this:: member_topics << Name topic_id member_id << have one of these in every table topic_title topic_date topic_content and in the friends one:: friends_table << name id member_id << id of the person who made the friend request friend_id << id of the person accepted the friend request is_friend << if 0 friend request pending all works nice as pic however i only want to show posts to those who are friends so if i go on my profile section i will see all my friends topics and they will see mine but i cant seem to fathem out the query i have tried many ways im confused i can get it to show mine no problem. any suggestions? hope someone can help Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/211549-php-bit-confused-with-a-query/ Share on other sites More sharing options...
jcbones Posted August 23, 2010 Share Posted August 23, 2010 Try $id = 'member_id'; //members id you are searching for. $sql = "SELECT a.*,b.* FROM member_topics as a, friends_table as b WHERE (a.member_id = b.member_id OR a.member_id = b.friend_id) AND ((b.member_id = '$id' OR b.friend_id = '$id') AND b.is_friend = 1)"; UN-TESTED. Quote Link to comment https://forums.phpfreaks.com/topic/211549-php-bit-confused-with-a-query/#findComment-1102885 Share on other sites More sharing options...
JonnySnip3r Posted August 23, 2010 Author Share Posted August 23, 2010 thanks dude will give it ago Quote Link to comment https://forums.phpfreaks.com/topic/211549-php-bit-confused-with-a-query/#findComment-1102891 Share on other sites More sharing options...
JonnySnip3r Posted August 23, 2010 Author Share Posted August 23, 2010 ITS ALIIIIVEEE needed to tweak the query abit but thankyou very much!!! Quote Link to comment https://forums.phpfreaks.com/topic/211549-php-bit-confused-with-a-query/#findComment-1102913 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.