Image

Imagetrg_lazurus wrote in Imagephp

Okay. Imagedarkrose and I are trying to get a selectable list to highlight specific options. As this runs through, it's suppose to match the two values to the DB and then parse the "option selected" string and the "opton not selected" string when it's false. Infortunately, it's a mystery as to why this doesn't work. Can someone please take a look at the code and see if it's a logic issue or if it's something larger?


$cats=mysql_query("select * from category where parent='0' order by catname");
$prodcat=mysql_query("select catid from productcats where prodid='$_REQUEST[pid]'");
$get_prodcat=mysql_fetch_array($prodcat);

while($get_cats=mysql_fetch_array($cats)){
$catid=$get_cats[catid];
if(@in_array($catid, $get_prodcat)){
$catoutput.= "<option selected value=\"$get_cats[catid]\" class=\"parentcat\">$get_cats[catname]</option>";
}else{
$catoutput.= "<option value=\"$get_cats[catid]\" class=\"parentcat\">$get_cats[catname]</option>";
}

$topcatid=$get_cats[catid];
$children=mysql_query("select * from category where parent='$topcatid' order by catname");

while($get_children=@mysql_fetch_array($children)){
$childid=$get_children[catid];
if(@in_array($childid, $get_prodcat)){
$catoutput.= "<option selected value=\"$get_children[catid]\" class=\"childcat\">$get_children[catname]</option>";
}else{
$catoutput.= "<option value=\"$get_children[catid]\" class=\"childcat\">$get_children[catname]</option>";
}
}
}
}