this is an old query i've been remodelling to work with an ever changing script (any suggestions as to its cleanliness and efficiency are most welcome)...
i'm trying to print "$line <a href// Playlist</a>" ONLY IF any number of cats with the value of 518 exist for each userid. doesn't matter how many records with such a cat - that's handled elsewhere. i just don't want to print that line if there are no 518s for $userid.
can anyone show me the error of my ways? (not like my mom tried to show me - that NEVER worked).
thanks, in all seriousness, and regards,
gn
$res = mysql_query("SELECT id, userid, user, cat, bigimage, description, extra1 FROM pp_photos ORDER BY rating DESC");
while ($row = mysql_fetch_array($res)) {
$img = $row["bigimage"];
$bio = $row["description"];
$url = $row["extra1"];
$userid = $row["userid"];
$name = $row["user"];
$id = $row["id"];
$cat = $row["cat"];
$catArray[] = $cat;
$mp3Array[] = $mp3;
$picsArray[] = $img;
$useridArray [] = $userid;
$nameArray[] = $name;
$urlArray[] = $url;
$idArray[] = $id;
$bioArray[] = $bio;
}
$idx = 0;
$pos = 0;
$purl = $picUrl[$pic];
$i = (count($picsArray) - 1);
while ($idx <= $i)
{
$pic = $picsArray[$idx];
$url = $urlArray[$idx];
$name = $nameArray[$idx];
$cat = $catArray[$idx];
$userid = $useridArray[$idx];
$id = $idArray[$idx];
$bio = $bioArray[$idx];
$name = str_replace("'", "\'", $name);
$bio = str_replace("'", "\'", $bio);
$bio = preg_replace("/"/", "\'", $bio);
$bio = preg_replace("/'/", "\'", $bio);
if ($pos == 0) { print "<tr>\n"; }
$line = "<a href=\"pp/showphoto.php?photo=$id&cat=$cat&ppuser=$userid\" target=\"\" onmouseover=\"return overlib ('<b><a href=$url target=_blank>Website</a></b><br><img src=imgs/spacer.gif width=100 height=3><br>";
$resa = mysql_query("SELECT cat FROM pp_photos WHERE cat = '518' AND userid = '$userid' LIMIT 1");
while ($row = mysql_fetch_array($resa)) {
$mp3 = $row["cat"];
echo "$mp3";
}
if ($mp3 = '518') {
$line .= "<b><a href=mediaPlayer/player.php?userid=$userid target=player>Playlist</a> </b>";
}
$line .= "<br><////////////></a>";