Jump to content

need help with simple query, please...


glennn.php

Recommended Posts

the kind of help i need is with this stupid little query that i can't make behave...

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



[code]
$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("/&quot;/", "\'", $bio);
$bio = preg_replace("/&#039;/", "\'", $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><img src=imgs/spacer.gif width=100 height=3><br><b>$bio</b><br><img src=imgs/spacer.gif width=100 height=3>', STICKY, CAPTION, '<b>$name</b>', MOUSEOFF);\" onmouseout=\"return nd();\"><img src=\"pp/data/".$cat."/".$pic."\" border=\"0\" height=\"100\" width=\"100\"></a>";

[/code]
Link to comment
Share on other sites

you mean all that looks right except for THAT??? i'm picking myself up off the floor laughing. i've attempted every reasonable script configuration known to man, woman and dolphin, and ...

well. i'm a novice. let's go give this a try. i'll let you know. TIA.
Link to comment
Share on other sites

let me clarify -

i want to print that particular portion of $line ONLY IF a cat with value 518 exists for $userid. for some reason the query as i have it now prints that line whether the userid possesses a cat of 518 or not (all userid's possess a cat of something else - some ALSO have a 518, or two or several, in which case i'd want the link "Playlist" printed along with the other info...)

hope that clarifies my Greek for whomever is inclined to assist this lost soul.

TIA
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.