Hi All,
I want to add data for the time tables. I have created 3 fields namely grade, class and stream which is only relevant for advanced level classes. otherwise the "stream" field should be disabled. In my database the class table and grade tables were already populated with data. But when i am trying to select from the drop down list no classes were get selected. It automatically selected grade "1" everytime. I have posted my coding. Can anyone show me where i went wrong?
<?php
$grdid=isset($_POST['grade_ID']) ? $_POST['grade_ID'] :'';
$query="SELECT * FROM grade";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)){
if($grdid==$row['grade_id']){
echo "<option selected value=\"".$row['grade_id']."\">".$row['grade']."</option> \n ";
}else{
echo "<option value=\"".$row['grade_id']."\">".$row['grade']."</option> \n ";
}
}
?>
</select></td>
<td width="1" align="center"> </td>
<td align="center"><label>Class</label> </td>
<td width="71">
<select name="class_ID" id="jumpMenu2" >
<?php
$grdid=isset($_POST['grade_ID']) ? $_POST['grade_ID'] :'';
$query="SELECT class_name FROM class where grade_id='$grdid'";
$result=mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo "<option value=\"".$row['class_name']."\">".$row['class_name']."</option> \n ";
}
?>