Hello,
I am running out of time on this project and really need some assisistance on my last issue. I have three dropdowns, grade, teacher, and site. Data is pulled from 2 SQL tables, site and reading. When I open the form, there is a "0" in the grade form (as intended), nothing in the second, which is OK. The problem is with the third. It doesn't exist, but all of the values that should go into it are listed without a dropdown box. As soon as I select a grade level in the first dropdown, all three lists appear correctly and everything works perfectly.
Do I need to assign an initial value to the dropdowns (how??), or am I doing something else wrong????
Thanks for any assistance!
CJY
BTW - the problem in the original post was that I was carefully comparing different data types in my MySQL query... DUHH... Thanks to all that reviewed the code!
Here's the current code:
<?php
## Assign connection values##
$db="reading";
$tbl1="site";
$tbl2="reading";
##Create db Connection Here - (is OK)##
## dropdown One - Grade Select (this one works)##
do query MySQL - get data to populate list
$query1 =mysql_query("SELECT Grade FROM $db.$tbl2 GROUP BY Grade");
loop to get values from database and list
echo "<select name = grd onchange = document.selectform.submit()";
while(list($grade) = mysql_fetch_row($query1))
{
echo "<option value=$grade";
if ($grade == $grd) { echo " selected"; }
echo ">$grade</option>";
}
echo "</select >";
#### dropdown Two - Teacher Select (also works)####
do query MySQL - get data to populate list
echo "<select name = tchr onchange = document.selectform.submit()";
$query2 =mysql_query("SELECT Teacher FROM $db.$tbl2 WHERE Grade = '$grd' GROUP BY Teacher");
loop to get values from database and list
while(list($Teacher) = mysql_fetch_row($query2))
{
echo "<option value=$Teacher";
if ($Teacher == $tchr) { echo " selected"; }
echo ">$Teacher</option>";
}
echo "</select> ";
#### dropdown Three - School Select (blows up) ####
do query MySQL - get data to populate list
$query3 =mysql_query("SELECT Site_ID FROM $db.$tbl1 GROUP BY Site_ID");
loop to get values from database and list
echo "<select name = mysite onchange = document.selectform.submit()";
while(list($Site_ID) = mysql_fetch_row($query3))
{
echo "<option value=$Site_ID";
if ($Site_ID == $mysite) { echo " selected"; }
echo ">$Site_ID</option>";
}
echo "</select> ";
?>
<?php