0

Hi guys, I am in need of a simple friends list code. I don't know how to start it, but I have gotten an idea, maybe anyone of you can help?

I have setup a database with login and password, I want to also add a Friends column. I will setup a "Profile page" soon, and from there I want a button to add that person. It simply puts the name of the person in the Friends column and adds a comma.

When reading the column it should go to a next line as soon as it sees a comma, thus separating the friends.

Any help? Or if you have a simple friends script that works and you would be generous enough to let me use it, that would be great.

-Toxikr3

5
Contributors
5
Replies
7
Views
7 Years
Discussion Span
Last Post by Toxikr3
0

You would need a SELECT statement in SQL to do this, the same way you inserted all of your friends to the database just ...

SELECT id,firstName,lastName FROM Profiles WHERE isVisible='1'

of course you will need to change the names based on your table structure.

0

I just accomplished this :) but with the guy above has the right idea it's all about mysql queries and narrow them down which takes time to do but worth it at the end!

I don't think anyone will share the source :icon_lol: but then again you might just find one person who is lovely that wants to give you a piece of cake. Good luck with it, sorry this reply hasn't been useful but hope it sheds some light on the idea :) Got any questions I'll be gladly to help you.

0

you can Also do like this
1.create a separate table call it friends with fields ,friend and username.
2.when someone is logged in and wants to add A friend he inserts
two rows.

mysql_query(INSERT INTO friends (friend,username) VALUES('$friend','$username'));

mysql_query(INSERT INTO friends (friend,username) VALUES('$username','$friend'));

when displaying friends list
just like this

SELECT *FROM friends WHERE username="$username";

Dont forget to include the friendsRequest table to insure that u just add someone u wish to be ur friend.

0

WRT your original idea, I'd advise against having a comma separated list in your friends column. This would make it difficult to search friends. You need a dedicated friends table:

friend_id (autonumber/int)
user_id (int : foreign key on user_id in user table)
friend_id (int : foreign key on user_id in user table)
status (tinyint : e.g. 0 = not accepted yet, 1= accepted, 2 = declined)

This should work with an invitation to be a friend system. Or if you just want to add (like Daniweb's system), no need for status column.

0

Thank you for the replys guys, it has given me an idea to work around with. I'll try it out and see if it works.

Though I am wondering how to send the confirm message to the certain person.

-Toxikr3

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.