warclown Posted July 4, 2007 Share Posted July 4, 2007 Hi. Im making a website with userprofiles which includes a buddylist that I want to make. The database contains two different tables (x_users and x_buddylist). x_users table: id , username 1 , warclown 2 , Leffa 3 , Testman x_buddylist: bid , ownerid , friendid 1 , 1 , 2 2 , 1 , 3 3 , 3 , 2 4 , 3 , 1 As you already probably understand: ownerid is the userid (from x_users) aka the owner of the relationship, and friendid is the friend that has been added (also the userid from x_users). The problem im facing is how to extract the information I want. Ive been told that MySQL JOIN is the way to do it, but all the guys Ive asked to help me understand the JOIN method has said the same thing "Read the manual, its hard to explain". So I tried to learn the manual... many times, and i still dont understand how to extract the buddylist of f.ex user 1 (warclown in this case). I want the buddylist to extract this info: <a href='user.php?uid=(THE FRIENDID)'>(The Friend Name)</a> Etc (The same thing over again downwards after how many friends the user has added. Can anyone give me a spesific example on how to do this on my site (just write the examples after my tables and rows given above). I know that I will learn more by seeing exactly what I shouldve done combined with the theory on the mysql manual site. Please help Best regards, Simen 'warclown' Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted July 4, 2007 Share Posted July 4, 2007 Query: Select * from x_users as u,x_buddylist as b where u.id=b.ownerid This is just an example u can modify it for ur script. Quote Link to comment Share on other sites More sharing options...
warclown Posted July 4, 2007 Author Share Posted July 4, 2007 Actually I came that far by myself. But my main problem was how to echo it. How can I echo the users in the buddylist ? I need the PHP code to retrieve the ones that is specified by the userid - and I need it to get the friend id's and automatically retrieve the username of that friendid so I can echo it out. It sounds complex Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.