| | |
Friends list
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2009
Posts: 27
Reputation:
Solved Threads: 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
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
You would need a SELECT statement in SQL to do this, the same way you inserted all of your friends to the database just ... of course you will need to change the names based on your table structure.
PHP Syntax (Toggle Plain Text)
SELECT id,firstName,lastName FROM Profiles WHERE isVisible='1'
•
•
Join Date: Jul 2009
Posts: 5
Reputation:
Solved Threads: 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
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.
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
Got any questions I'll be gladly to help you. •
•
Join Date: Mar 2008
Posts: 217
Reputation:
Solved Threads: 4
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.
when displaying friends list
just like this
Dont forget to include the friendsRequest table to insure that u just add someone u wish to be ur friend.
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)
mysql_query(INSERT INTO friends (friend,username) VALUES('$friend','$username')); mysql_query(INSERT INTO friends (friend,username) VALUES('$username','$friend'));
just like this
php Syntax (Toggle Plain Text)
SELECT *FROM friends WHERE username="$username";
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.
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.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
![]() |
Similar Threads
- I want do that the users can view the last activities of her friends (PHP)
- Friends request in PHP (PHP)
- do i have a limit to my friends list (Geeks' Lounge)
- invitation for Yahoo IM id's (Geeks' Lounge)
- Solaris 5.8-Unidetified file (*nix Software)
Other Threads in the PHP Forum
- Previous Thread: php mysql checkbox help
- Next Thread: How we open a ms word document file with php?
| Thread Tools | Search this Thread |
ajax apache api array basics beginner binary bounce broken cakephp checkbox class cms code codingproblem combobox cron curl database date display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla js limit link login loop mail menu mlm mobile multiple mysql nodes oop outofmemmory paging parse paypal pdf php problem procedure query radio ram random recursion regex remote return script search server sessions smash sms soap source space sql syntax system table tutorial up-to-date update upload url validation validator variable video web webapplications websitecontactform xml youtube






