dynamic drop down menus

blondegeek

Baseband Member
Messages
23
I got this script off of plus2net.com (if you want the code its at http://www.plus2net.com/php_tutorial/dd3.zip) and it isn't working for me.

PHP:
<?


///////// Getting the data from Mysql table for first list box//////////
$quer2=mysql_query("SELECT DISTINCT style_name,style FROM products WHERE logo='proto' order by style"); 
///////////// End of query for first list box////////////

/////// for second drop down list we will check if category is selected else we will display all the subcategory///// 
$cat=$HTTP_GET_VARS['cat']; // This line is added to take care if your global variable is off
if(isset($cat) and strlen($cat) > 0){
$quer=mysql_query("SELECT * FROM products where style=$cat AND logo='proto' AND stock > 0"); 
}else{$quer=mysql_query("SELECT * FROM products where style=$cat AND logo='proto' AND stock > 0"); } 
////////// end of query for second subcategory drop down list box ///////////////////////////


/////// for Third drop down list we will check if sub category is selected else we will display all the subcategory3///// 
$cat3=$HTTP_GET_VARS['cat3']; // This line is added to take care if your global variable is off
if(isset($cat3) and strlen($cat3) > 0){
$quer3=mysql_query("SELECT * FROM products where size=$cat3 AND style=$cat AND logo='proto' "); 
}else{$quer3=mysql_query("SELECT * FROM products where size=$cat3 AND style=$cat AND logo='proto' "); } 
////////// end of query for third subcategory drop down list box ///////////////////////////


echo "<form method=post name=f1 action=''>";
//////////        Starting of first drop downlist /////////
echo "<select id=\"menu1\" name='cat' onchange=\"reload(this.form)\"><option value=''>--Style--</option>";
while($noticia2 = mysql_fetch_array($quer2)) { 
if($noticia2['style']==@$cat){echo "<option selected value='$noticia2[style]'>$noticia2[style_name]</option>"."<BR>";}
else{echo  "<option value='$noticia2[style]'>$noticia2[style_name]</option>";}
}
echo "</select>";
//////////////////  This will end the first drop down list ///////////

//////////        Starting of second drop downlist /////////
echo "<select id=\"menu2\" name='subcat' onchange=\"reload3(this.form)\"><option value=''>--Size--</option>";
while($noticia = mysql_fetch_array($quer)) { 
if($noticia['size']==@$cat3){echo "<option selected value='$noticia[size]'>$noticia[size]</option>"."<BR>";}
else{echo  "<option value='$noticia[size]'>$noticia[size]</option>";}
}
echo "</select>";
//////////////////  This will end the second drop down list ///////////


//////////        Starting of third drop downlist ///////// 
echo "<select id=\"menu3\" name='subcat3' ><option value=''>--Quantity--</option>"; 
while($noticia = mysql_fetch_array($quer3)) { 
$stock      = stripslashes( $noticia['stock'] ); 
if ($stock < 5) { 
   for ($i = 1; $i <= $stock; $i++) { $number = $i; } 
            } 
else { for ($i = 1; $i <= 5; $i++) { $number = $i; } 
            } 
echo  "<option value='$number'>$number</option>"; 
} 
echo "</select>"; 
//////////////////  This will end the third drop down list /////////// 


echo "</form>"; 
?>

I think this is the chunk with the issues (kinda vague, I know but I do what I can). sooo I keep getting this oh so lovely error that says "mysql_fetch_array(): supplied argument is not a valid MySQL result resource" which is slightly angering since that is just about the only part I didn't change. Any ideas? Thanks in advance.
 
Back
Top Bottom