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
Add Freinds - Please Help!!!
Moderator: General Moderators
Re: Add Freinds - Please Help!!!
how far have you gone with your code ?
Re: Add Freinds - Please Help!!!
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"
There's a lot more to take into consideration, but that should be a good start for you.
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';
Re: Add Freinds - Please Help!!!
thanks, that helped me a lot. If I have any more question i'll ask them hereastions 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"
There's a lot more to take into consideration, but that should be a good start for you.Code: Select all
SELECT friend_id FROM friends WHERE user_id = '1';
Re: Add Freinds - Please Help!!!
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
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