View Full Version : Question from a newbie

10-28-2005, 05:15 PM
Heres my problem:
Ive three drop down boxes on this form that I want to populate dynamically.
The first populates fine.
The second doesnt populate at all.
The third shows everything and doesnt take user choices into account.
Im at my wits end trying to figure this out.

Here's my code:


// username and password to log onto db server
// name of database

////// DONOT EDIT BELOW /////////
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());

<!doctype html public "-//w3c//dtd html 3.2//en">


<title>Upload screen attempt</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
<SCRIPT language=JavaScript>
function reload(form)
var val=form.Style.options[form.Style.options.selectedIndex].value;
self.location='dd3.php?Style=' + val ;
function reload3(form)
var val=form.Style.options[form.Style.options.selectedIndex].value;
var val2=form.classifications.options[form.classifications.options.selectedIndex].value;

self.location='dd3.php?Style=' + val + '&Item_Type=' + val2 ;



///////// Getting the data from Mysql table for first list box//////////
$quer2=mysql_query("SELECT DISTINCT ID,Name FROM Styles");
///////////// 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/////
$Style=$HTTP_GET_VARS['Style']; // This line is added to take care if your global variable is off
$quer=mysql_query("SELECT DISTINCT ID,Name FROM classifications where ID=$Style");
}else{$quer=mysql_query("SELECT DISTINCT ID,Name FROM classifications"); }
////////// 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/////
$Item_Type=$HTTP_GET_VARS['Item_Type']; // This line is added to take care if your global variable is off
$quer3=mysql_query("SELECT DISTINCT Name FROM Item_Types where ID=$Item_Type");
}else{$quer3=mysql_query("SELECT DISTINCT Name FROM Item_Types"); }
////////// end of query for third subcategory drop down list box ///////////////////////////

echo "<form method=post name=Upload attempt action=''>";
////////// Starting of first drop downlist /////////
echo "<select name='Style' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['ID']==@$Style){echo "<option selected value='$noticia2[ID]'>$noticia2[Name]</option>"."<BR>";}
else{echo "<option value='$noticia2[ID]'>$noticia2[Name]</option>";}
echo "</select>";
////////////////// This will end the first drop down list ///////////

////////// Starting of second drop downlist /////////
echo "<select name='classifications' onchange=\"reload3(this.form)\"><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option selected value='$noticia[ID]'>$noticia[classifications]</option>"."<BR>";
echo "<option value='$noticia[Name]'>$noticia[classifications]</option>";
echo "</select>";
////////////////// This will end the second drop down list ///////////

////////// Starting of third drop downlist /////////
echo "<select name='Item_Type' ><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer3)) {
echo "<option value='$noticia[Name]'>$noticia[Name]</option>";
echo "</select>";
////////////////// This will end the third drop down list ///////////

echo $noticia['ID'];
echo $noticia2['ID'];
echo "</form>";
<center><a href='http://www.mcnallydesign.com'></a></center>


10-28-2005, 06:08 PM
way beyond me but this is defo out there on google

plenty of people have struggled with this and won, involves arrays and javascript as I recall

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum