Go Back   Computer Forums > Web Design | Website Development > Web Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 06-27-2006, 10:24 AM   #1
Baseband Member
Join Date: Jan 2006
Posts: 23
Default dynamic drop down menus

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 Code:

///////// 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"); 
$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' "); 
$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>";
$noticia2 mysql_fetch_array($quer2)) { 
$noticia2['style']==@$cat){echo "<option selected value='$noticia2[style]'>$noticia2[style_name]</option>"."<BR>";}
"<option value='$noticia2[style]'>$noticia2[style_name]</option>";}
//////////////////  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>";
$noticia mysql_fetch_array($quer)) { 
$noticia['size']==@$cat3){echo "<option selected value='$noticia[size]'>$noticia[size]</option>"."<BR>";}
"<option value='$noticia[size]'>$noticia[size]</option>";}
//////////////////  This will end the second drop down list ///////////

//////////        Starting of third drop downlist ///////// 
echo "<select id=\"menu3\" name='subcat3' ><option value=''>--Quantity--</option>"
$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; } 
"<option value='$number'>$number</option>"

//////////////////  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.

blondegeek is offline   Reply With Quote
Old 06-27-2006, 11:11 AM   #2
Baseband Member
Join Date: Jan 2006
Posts: 23
Default Re: dynamic drop down menus

nevermind, figured it out. you have to put `` around all the cell and table names
blondegeek is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 08:48 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0