Page 1 of 1
Add Freinds - Please Help!!!
Posted: Thu Apr 30, 2009 9:23 pm
by kedora19
how would you make a script that lets people add friends.
I have a view users script that takes you to there profile page, but what kind of code would i use to make a add friend button and add that name under your friends section.
also how would my database look like. Would i have one column for user_name of the friends and another column with the user name of the person that add them.
if you need an example, look at facebook. you can add friends by pressing a button (for now take out the allow friend button).
Thanx, Kedora19
Re: Add Freinds - Please Help!!!
Posted: Fri May 01, 2009 12:17 am
by it2051229
how far have you gone with your code ?
Re: Add Freinds - Please Help!!!
Posted: Fri May 01, 2009 2:52 am
by Benjamin
Assuming you have a table of users, there should be a primary key.
So using the primary key from your users table, you can then create a friends table.
The friends table would contain the following fields:
id primary key auto increment
user_id index
friend_id index
So now you can track who is friends with who by storing their user_id and the user_id of their friends.
To get a list of friends for user 1, you use the following query"
Code: Select all
SELECT friend_id FROM friends WHERE user_id = '1';
There's a lot more to take into consideration, but that should be a good start for you.
Re: Add Freinds - Please Help!!!
Posted: Fri May 01, 2009 9:26 am
by kedora19
astions wrote:Assuming you have a table of users, there should be a primary key.
So using the primary key from your users table, you can then create a friends table.
The friends table would contain the following fields:
id primary key auto increment
user_id index
friend_id index
So now you can track who is friends with who by storing their user_id and the user_id of their friends.
To get a list of friends for user 1, you use the following query"
Code: Select all
SELECT friend_id FROM friends WHERE user_id = '1';
There's a lot more to take into consideration, but that should be a good start for you.
thanks, that helped me a lot. If I have any more question i'll ask them here
Re: Add Freinds - Please Help!!!
Posted: Fri May 01, 2009 9:35 am
by kedora19
one more question, how how would I use a variable link to add it to the database.
ex. (I use variable to get the user to there page) so when it loads the page. you see the persons name, you click it and it takes it to there page, but how would I add another link there so it would send the persons name to the database
thanx
