No data from second list

gwhite12
07:24:11
I modified the code to reflect my tables.
Here is the code:


@$id=$HTTP_GET_VARS['D_ID'];
///@$id=$_GET['D_ID']; // Use this line or below line if register_global is off
if(strlen($id) > 0 and !is_numeric($id)){ // to check if $cat is numeric data or not.
echo "Data Error";
exit;
}

///////// Getting the data from Mysql table "Directory" for first list box//////////
$quer2=mysql_query("SELECT DISTINCT directory, D_ID FROM directory order by directory");
///////////// End of query for first list box////////////

/////// for second drop down list we will check if "D_ID" is selected else we will display all the "Names"/////
if(isset($id) and strlen($id) > 0){
$quer=mysql_query("SELECT DISTINCT name FROM images where D_ID=$id order by name");
}else{$quer=mysql_query("SELECT DISTINCT name FROM images order by name"); }
////////// end of query for second image drop down list box ///////////////////////////

echo "<form method=post name=f1 action='dd-check.php'>";

/// Add your form processing page address to action in above line. Example action=dd-check.php////
////////// Starting of first drop downlist /////////
echo "<select name='id' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['D_ID']==@$id){echo "<option selected value='$noticia2[D_ID]'>$noticia2[directory]</option>"."<BR>";}
else{echo "<option value='$noticia2[D_ID]'>$noticia2[directory]</option>";}
}
echo "</select>";
////////////////// This will end the first drop down list ///////////

////////// Starting of second drop downlist /////////
echo "<select name='image'><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option value='$noticia[I_ID]'>$noticia[name]</option>";
}
echo "</select>";
////////////////// This will end the second drop down list ///////////
//// Add your other form fields as needed here/////
echo "<input type=submit value=Submit>";
echo "</form>";


dd-check tells me that I have empty set.

Value of $id =
Value of $image =

I can't seem to get the following line to get data.

$quer=mysql_query("SELECT DISTINCT name FROM images where D_ID=$id order by name");


Can you see my mistake?
Thanks for the help.
gwhite12
07-25-2011
Found error. It was a "DUH" moment.
Thanks

New question, How do I pas a second variable from the first drop down list?
I need to pass 'directory as $path' along with $cat and $subcat to dd-check.php

Thanks
webgoonie
09-25-2011
Gwhite try copying the option for the third value and change the name of sub cat and pass it over. Have you solved this yet?
cabalsdemon
06-08-2012
ok do you need 3 drop downs right
Please Login to post your reply or start a new topic