doooby
01-02-2005, 11:01 AM
Hello,
I'm using a Top 5 for my script and I want to cache all the top 5 tracks for the artists I have, What I want to do is for each artist's top 5 tracks there's a .cache file actually when I run the code below it runs the 2nd query ($dbh) for all the artists and not one artist at a time, So what Am I Doing wrong? Help Is Appreciated. Thanks
$data = array();
$fromtimes = strtotime($fromtime);
$dbr = mysql_query("SELECT artists FROM id3s WHERE artists LIKE \"Z%\" AND album != \"\" GROUP BY artists ORDER BY artists ASC");
while($result2 = mysql_fetch_array($dbr)){
print $result2['artists'];
$dbh = mysql_query("SELECT downloads.counter, id3s.iid, id3s.name FROM id3s INNER JOIN downloads ON id3s.file = downloads.file
WHERE artists LIKE \"" . $result2['artists'] . "\" AND id3s.file LIKE \"%.mp3\" GROUP BY id3s.name ORDER BY counter DESC LIMIT 5");
$result = mysql_fetch_assoc($dbh);
$data[] = $result;
$fp = fopen($result2['artists'] . ".cache", "w");
fwrite($fp, serialize($data));
fclose($fp);
}
I'm using a Top 5 for my script and I want to cache all the top 5 tracks for the artists I have, What I want to do is for each artist's top 5 tracks there's a .cache file actually when I run the code below it runs the 2nd query ($dbh) for all the artists and not one artist at a time, So what Am I Doing wrong? Help Is Appreciated. Thanks
$data = array();
$fromtimes = strtotime($fromtime);
$dbr = mysql_query("SELECT artists FROM id3s WHERE artists LIKE \"Z%\" AND album != \"\" GROUP BY artists ORDER BY artists ASC");
while($result2 = mysql_fetch_array($dbr)){
print $result2['artists'];
$dbh = mysql_query("SELECT downloads.counter, id3s.iid, id3s.name FROM id3s INNER JOIN downloads ON id3s.file = downloads.file
WHERE artists LIKE \"" . $result2['artists'] . "\" AND id3s.file LIKE \"%.mp3\" GROUP BY id3s.name ORDER BY counter DESC LIMIT 5");
$result = mysql_fetch_assoc($dbh);
$data[] = $result;
$fp = fopen($result2['artists'] . ".cache", "w");
fwrite($fp, serialize($data));
fclose($fp);
}
