0

I want to create facebook style friends system How to send,accept and manage friendship?

can anyone help me?

Thanks.

2
Contributors
3
Replies
7
Views
6 Years
Discussion Span
Last Post by sudeepjd
0

Have you started out with the code for the friends system project. Start writing the code and we can help you out with it.

Here's a tip to start.

Create a table for the friends. The format of the database could be one of 2 ways

1. The table would contain a username as the primary key and a column where the friends would be stored. The friends for the person would be a string with the id's of the users who are his friends in a comma separated user format. This can then be broken down into an array.

2. The table would not have a primary key and would just like the friends together. in a User<->Friend format. So when 2 people are linked together in the db this way, you know they are friends.

So start on the code and we'll help you on your way.

0

Have you started out with the code for the friends system project. Start writing the code and we can help you out with it.

Here's a tip to start.

Create a table for the friends. The format of the database could be one of 2 ways

1. The table would contain a username as the primary key and a column where the friends would be stored. The friends for the person would be a string with the id's of the users who are his friends in a comma separated user format. This can then be broken down into an array.

2. The table would not have a primary key and would just like the friends together. in a User<->Friend format. So when 2 people are linked together in the db this way, you know they are friends.

So start on the code and we'll help you on your way.

**********************************************************************

Database: `friendrequest`

--Table structure for table `friend_requests`--


CREATE TABLE IF NOT EXISTS `friend_requests` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sender` int(11) NOT NULL,
`recipient` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM ;


-- Table structure for table `members`--


CREATE TABLE IF NOT EXISTS `members` (
`member_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`firstname` varchar(100) DEFAULT NULL,
`lastname` varchar(100) DEFAULT NULL,
`login` varchar(100) NOT NULL DEFAULT '',
`passwd` varchar(32) NOT NULL DEFAULT '',
`friends` text NOT NULL,
PRIMARY KEY (`member_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;


I have created database but I am confused how to send request and manage friends.

login= user name logged in
friends= friends of user logged in

When request is accepted it should be removed from table `friend_requests`

Is there need to create one more table "friends" to store friends of user?

Please Help me

Thanks.

1

Good. You have started.

This database structure will work. However, instead of creating the friends_request table, create a friends table. This would have the following fields,

ID - Friend1 - Friend2 - Request

Request wound contain say t for temporary and p for permanent. The convention can be changed for your convenience

When a message is sent from Friend 1 to Friend2 store the data as follows.

1 - SudeepJD - vizz - t

The t above states that the request is still active and is not confirmed by friend 2. When Friend2 receives the request, he can accept or reject it.

On acceptance, change the t to p to say that the request is now permanent. Once this is done, you know that it is no longer a request.

If rejected, delete the row from the database.

From this table, you can also manage friends by searching for the username is both Friend 1 and Friend 2 and displaying the counterpart data.

Let me know if you are stuck somewhere.

Edited by sudeepjd: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.