| | |
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 |
apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date display dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include incode insert integration ip javascript joomla limit link login mail match menu method mlm mod_rewrite multiple mysql oop pageing pagerank paypal pdf php problem query radio random recursion recursiveloop remote script search server sessions sms smtp soap source space sql strip_tags subversion support! survey syntax system table template tutorial undefined update upload url validator variable video virus web window.onbeforeunload=closeme; youtube





