php friend request system help
php friend request system help
ok since temor has finally helped me make my commenting system work now i need help on a friend request system so if anyone can help me can you give me basic ideas on how to create a friend request system?
Re: php friend request system help
I find the database is always a good place to start. So you want a way to store a link between two users. Once way would be to have two columns, one for the users ID and one for the user ID of the friend. Set that up in phpmyadmin first
Then you need to work out how to manipulate that from your script, so write out the skeleton of the functions you will probably need
Have a play with the functions on a test page and make sure the results are right, then use them to make the page.
You can always make a more specific post if you get stuck at any point
Then you need to work out how to manipulate that from your script, so write out the skeleton of the functions you will probably need
function is_friend($user_id){ } function fetch_all_friends(){ } function add_friend($user_id){ } function remove_friend($user_id){ }Start at the top and try to work out what queries you need to run to get the information for each one.
Have a play with the functions on a test page and make sure the results are right, then use them to make the page.
You can always make a more specific post if you get stuck at any point
Re: php friend request system help
okay I am really sorry but I have done this so far and I am still confused....
its mainly because i'm still learning php at the basics...
here is what i have done so far...
user.inc.php:
i added the code that you gave me.
and for the sql I did this:
user_id & friend_id both with a normal int
i am mainly confused because I did try to do a mysql_query but I don't know how to start it up :\
its mainly because i'm still learning php at the basics...
here is what i have done so far...
user.inc.php:
i added the code that you gave me.
and for the sql I did this:
user_id & friend_id both with a normal int
i am mainly confused because I did try to do a mysql_query but I don't know how to start it up :\
Re: php friend request system help
Could you post what you tried ? Pretty hard to help without knowing the problem
Re: php friend request system help
ok i was thinking about something like this since it would be easier to do....
first i would make the friends table and do this...
The SQL:
id = auto_increment
user_id = id from the main table representing the user_id of the user
and make a form that submits these into the database
the friend id's from 0 - 3:
if they are not friends = 0
if they are friends = 1
if request not confirmed = 2
if request rejected = 3
for the depending requests on the 0 1 2 3
u can display his or her info.
also tell me if there is anyway to make this better written?
but im confused on how to do this meaning writing the code out....
first i would make the friends table and do this...
The SQL:
id = auto_increment
user_id = id from the main table representing the user_id of the user
and make a form that submits these into the database
the friend id's from 0 - 3:
if they are not friends = 0
if they are friends = 1
if request not confirmed = 2
if request rejected = 3
for the depending requests on the 0 1 2 3
u can display his or her info.
also tell me if there is anyway to make this better written?
but im confused on how to do this meaning writing the code out....
Re: php friend request system help
That could work yeah.
the way I did this was to have a table with 3 columns user_id, friend_id and approved
user_id is the id of the user you are talking about. when they send a friend request to a user you insert a row into the table with the friend_id being the id of the user they sent the request to and 0 for the approved column. then when the friend accepts the request you update the table setting approved to 1.
Obviously friendship is both ways, so if user_id is friends with friend_id then friend_id is also friends with user_id which makes getting a list of a given users friends a little tricky.
the way I did this was to have a table with 3 columns user_id, friend_id and approved
user_id is the id of the user you are talking about. when they send a friend request to a user you insert a row into the table with the friend_id being the id of the user they sent the request to and 0 for the approved column. then when the friend accepts the request you update the table setting approved to 1.
Obviously friendship is both ways, so if user_id is friends with friend_id then friend_id is also friends with user_id which makes getting a list of a given users friends a little tricky.
Re: php friend request system help
Thank You, jacek, for the startercode. I try to implement it to my website
Re: php friend request system help
No problem Good luckroenu wrote:Thank You, jacek, for the startercode. I try to implement it to my website