Jump to content

Recommended Posts

I am build a social network and Iam trying to implement a friends facility where one user adds another user as a friend.

 

My current friends system works one way e.g. If Mr A adds Mr B to as a friend and B approves of A, A will be connected with B (e.g. A will see B in his friends list) but B might not necessarily be connected with A (e.g. B in his friends list will not see a )

 

Here is the database/table designs and some queries am using in pulling out values.

 

 

CREATE TABLE IF NOT EXISTS `friends` (

  `id` int(11) NOT NULL auto_increment,

  `member_id` int(11) NOT NULL,

  `member` varchar(32) NOT NULL,

  `friendwith` varchar(32) NOT NULL,

  `friendWithId` int(11) NOT NULL,

  `status` varchar(32) NOT NULL,

  PRIMARY KEY  (`id`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=26 ;

 

To display the friends of a particular user i'd use the following query

 

SELECT fc.friendWithId, fc.friendWith, uu.image_path, uu.first_name, uu.last_name, uu.city, uu.gender, uu.relationship_status, uu.last_login FROM friends fc JOIN users uu ON fc.friendWithId = uu.user_id WHERE member_id = '%s' AND member = '%s' and fc.status='active' ", mysql_real_escape_string($userIdentifier), mysql_real_escape_string($userAlias)

 

This will list all the friends of a particular user.

 

The problem is I need to somehow display people who are firiends of a particular person and people who that particular person is friends with. e.g. I want Mr A to see Mr B in his friends list and I want Mr B to do likewise.

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/86153-two-way-friendship-system-problems/
Share on other sites

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.