Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 04-24-2008, 12:36 PM   #1
Baseband Member
 
Join Date: May 2005
Posts: 28
Send a message via Yahoo to mcfelpe
Default Php profile page

Good day everyone, I have a project and i need help on what approach should i do to my database, the project goes like this, It is a website in which each user will create their own profile. What should i do to my database so that the user can add another user member of the website, just like in friendster... wherein in my profile page, i can see my details, and at the right side, i can see my added friends...

Any suggestion will be highly appreciated... thank you....

by the way, i'm using html/flash/php/mysql
__________________

mcfelpe is offline   Reply With Quote
Old 04-24-2008, 08:58 PM   #2
Baseband Member
 
jonny912's Avatar
 
Join Date: Jun 2006
Posts: 80
Send a message via MSN to jonny912
Default Re: Php profile page

You should have a User table, with a user ID and all the user details, then perhaps column with a comma separated list of friends user ID's, then use PHP's explode() function to create an array of friends user IDs. You could then have a foreach loop go through the array, and grab info on the friend from the User table.
Code:
foreach($friendIDs as $friendID)
{
    $friendInfoResult = mysql_query("
    SELECT * FROM 
   `Users` 
    WHERE 
    `ID` = '" . $friendID . "'
    ");
    $friendInfo = mysql_fetch_assoc($friendInfoResult);
    // Then loop get all the other fields from friendInfo[0]["thefield"]
}
Note: There's probably a far more elegant solution in SQL itself, so good luck.
__________________

__________________
Computers are like air conditioners, they break when you open windows.
jonny912 is offline   Reply With Quote
Old 04-24-2008, 09:45 PM   #3
Baseband Member
 
Join Date: May 2005
Posts: 28
Send a message via Yahoo to mcfelpe
Default Re: Php profile page

Yes i think its a good idea, but my concern is how many characters does the friendsID field allow? what if a user have so many friends, so the friendsID field would be like jason,mark,phillip,etc,etc,etc,etc,etc and so on...
mcfelpe is offline   Reply With Quote
Old 04-24-2008, 10:47 PM   #4
Baseband Member
 
jonny912's Avatar
 
Join Date: Jun 2006
Posts: 80
Send a message via MSN to jonny912
Default Re: Php profile page

Quote:
Originally Posted by mcfelpe View Post
Yes i think its a good idea, but my concern is how many characters does the friendsID field allow? what if a user have so many friends, so the friendsID field would be like jason,mark,phillip,etc,etc,etc,etc,etc and so on...
You have a very valid point, perhaps you could have a separate table named Friends, and have a schema containing UserID and FriendUserID, then adding a row for each friend a user has. You could retrieve all the user's friends with something like this:
Code:
SELECT * FROM `Friends` WHERE `UserID` == $TheUsersID
__________________
Computers are like air conditioners, they break when you open windows.
jonny912 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 06:57 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0