Link to home
Start Free TrialLog in
Avatar of evibesmusic
evibesmusicFlag for United States of America

asked on

How to create a simple friends system?

Hello all,

I know that this request is probablly not an easy one cause I am assuming that it woudl require the creation of some tables as well as a bit of php scripting

but....

I would like to create a simple friends system like myspace for my site.  With that said, the amount of traffic on this site is minimal but, will grow with time.

Users should be able to: Add and Delete Friends, View Friend Requests, Deny Friend Requests, etc.

As I said, I know that this could be difficult but, if anyone had a starting point or a suggestion of where I could look to try and find a system that could do this, it would be most helpful.

Thank you very much...your guys are great!

EVibesMusic
Avatar of mankowitz
mankowitz
Flag of United States of America image

ok, here is a rough idea.

Your friends table will be very simple -- two columns, id and friendid. Each pair will be a particular record. Suppose you have people named 1-5, and 2 and 3 are friends and 3 and 4 are friends

friends
--------
id   friendid
2    3
3    4

Since all friendships are mutual, you could list 3's friends with

SELECT * FROM friends WHERE id='3' OR friendid='3'

Next step is to make the requests table. This table is only needs to work one way, meaning that one person is the requestor and the other is the requestee. It would have the same format as the friends table.

Suppose 3 logs in, and 1 has recently requested to befriend him.

SELECT * FROM requests WHERE id=3

This will give one record response, and 3 can decide if he wants to be friends with 1. If yes, you make an entry in the friends table. In either case, you remove the request from the requests table.
Avatar of evibesmusic

ASKER

I appologize about the last post...but, as listed...I am by no means a GURU on this subject.
I have read the post and understand the post above in theory but, it is in just that theory...

Can you explain how...if a new friend was added to the 'friends' database, that only has two colums (as stated above) would you be able to show multiple friends? Can you append the db using an UPDATE query so that each friend is recognized by an individual number aka friend id?

So I gues what I am asking is would the 'friendid' column's value look like this: 3,4,78,52 where each number represents a different friend?

Please let me know if I am making myself clear?

Thanks...EVibesMusic
ASKER CERTIFIED SOLUTION
Avatar of mankowitz
mankowitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for the response...I see what you are saying and have read the Wiki.

I was wondering if you have in your mind an order of things to do to get this project accomplished i.e.;
1. Create 'friends' db table
2. Create 'requests' db tabel
3. Create code to send requests
4. Create code to display friends
5. Create code to enable friend deletion...etc...

I know that their is always more than one way to skin a cat so if you have a better work flow that you think would get the job done could you please let me know?

Appreciate everything.

EVibesMusic
everything you have is good. You also need code to handle request acceptances and denials
O.k.  will take the next steps and report back with some questions, I'm sure.

Thanks

EVibesMusic