WoW Gold - Health 2007 - Debt Consolidation - Free Animated Greetings - Air Jordans

PDA

View Full Version : $5 Php Mysql Query Help


45n5
Jun 11th 2007, 4:35 pm
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.

121603
Jun 11th 2007, 6:06 pm
$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.. :)

45n5
Jun 11th 2007, 6:23 pm
cool, seems to be working, pm me your paypal

thanks