I'm struggling with a query in php and was wondering if anybody could take a stab at it. Reward is $5 send via paypal. I have a table of users and their friends like this Table1 --username--userfriend-- --mark-------melissa---- --mark-------tommy---- --mark-------cindy----- --melissa-----phillip----- I have another table with cds they own --username--cd---------------purchasedate--- --melissa-----purple raine------5-7-07 --melissa-----dance tonight----5-12-07 --tommy-----dock of the bay---5-01-07 Given a username, I want the query to grab all of the users friends, then grab the latest albums the friends have added. Example - if I query for mark it should tell me what albums mark's friends have added lately. The album table also contains other data I'd like to pull into the results So if mark went to his "friends" page, it would show his friends latest albums. Any thoughts? I need the query and php to loop through results. Thanks.
$query = "select a.userfriend as friend, b.cd as cd, b.otherdata as data from table1 a, table2 b where a.userfriend=b.username"; $rs = mysql_query($query); while($row = mysql_fetch_assoc($rs)){ echo $row['friend']." ".$row['cd']." ".$row['data']; } something like that..