943,559 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1700
  • PHP RSS
Jul 10th, 2009
0

Friends list

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Toxikr3 is offline Offline
28 posts
since Jul 2009
Jul 10th, 2009
0

Re: Friends list

You would need a SELECT statement in SQL to do this, the same way you inserted all of your friends to the database just ...
PHP Syntax (Toggle Plain Text)
  1. SELECT id,firstName,lastName FROM Profiles WHERE isVisible='1'
of course you will need to change the names based on your table structure.
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
Jul 11th, 2009
0

Re: Friends list

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 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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
xide007 is offline Offline
5 posts
since Jul 2009
Jul 11th, 2009
0

Re: Friends list

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.
php Syntax (Toggle Plain Text)
  1. mysql_query(INSERT INTO friends (friend,username) VALUES('$friend','$username'));
  2.  
  3. mysql_query(INSERT INTO friends (friend,username) VALUES('$username','$friend'));
when displaying friends list
just like this
php Syntax (Toggle Plain Text)
  1. 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.
Reputation Points: 17
Solved Threads: 8
Posting Whiz in Training
mrcniceguy is offline Offline
278 posts
since Mar 2008
Jul 11th, 2009
0

Re: Friends list

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.
Sponsor
Featured Poster
Reputation Points: 1046
Solved Threads: 942
Sarcastic Poster
ardav is offline Offline
6,661 posts
since Oct 2006
Jul 11th, 2009
0

Re: Friends list

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
Reputation Points: 10
Solved Threads: 0
Light Poster
Toxikr3 is offline Offline
28 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: php mysql checkbox help
Next Thread in PHP Forum Timeline: how to connect to mysql in wamp





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC