Jump to content

Recommended Posts

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!!

Link to comment
https://forums.phpfreaks.com/topic/211549-php-bit-confused-with-a-query/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

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