Jump to content

add friends system


geko21

Recommended Posts

Hi guys, im making a basic social networking site for a college project and I need to know how to make a system that will let logged in users add each other as friends but I carnt really find anything on google about how to start. Can anyone here help me or know a tutorial I can follow that will let me create something like this?

 

Thanks

Link to comment
Share on other sites

Well, it is assumed that each user will have a unique ID since they must log in. I would also assume you have the ability for users to view other user's profiles. So, on a user's profile page include a button (i.e. form)  or link which directs the browser to an "add friend" page. In the form or link pass the user ID of the user whose profile was being viewed. Then, on the processing page, use that value to save a record to identify the "friend" link.

 

This all assumes you understand how to build a database and make the php pages work with the database.

Link to comment
Share on other sites

google had plenty for me: http://www.google.co.uk/search?hl=en&q=friends+list+database+php&meta=

 

as above really, have a table called friends, and note I haven't given this much thought, with a userid | friendid | status | columns.

Only problem i would see is if obama added osama, obama would be the userid and osama would be friendid, whereas if it was osama adding first it would be reverse. This might cause other issues when checking if someone is already a friend on not, depending on who added who first.

 

 

add me as a friend once you have done it  :P

Link to comment
Share on other sites

google had plenty for me: http://www.google.co.uk/search?hl=en&q=friends+list+database+php&meta=

Only problem i would see is if obama added osama, obama would be the userid and osama would be friendid, whereas if it was osama adding first it would be reverse. This might cause other issues when checking if someone is already a friend on not, depending on who added who first.

 

i came across this problem with my site so i made a table for friend requests and a table for friends. once the request is confirmed delete it from the requests table and add their details to the friends table. more queries and it can probably be done better but it saved me confusion and complexity.

Link to comment
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.