Jump to content

Two way friendship system problems


progwihz@yahoo.com

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

Archived

This topic is now archived and is closed to further replies.

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