I have a form creating an absence form for teachers at a high school. I have 9 rows (for each of the 9 possible periods) and each row has a drop down box with a list of subs. Therefore, I need to create the same dropdown box 9 times.
I pull the subs from a database table as follows....
$sql_subbed="SELECT * FROM personnel where loc_id='".$row_name[loc_id]."' order by last_name";
$conn = db_absence_connect();
$result_subbed = mysql_query($sql_subbed,$conn);
Next, I do something like this to create the dropdown...
echo "<select name='subbed_0' onchange=\"reload3(this.form)\"><option value=''>Select one</option>";
while($row_subbed_0 = mysql_fetch_array($result_subbed)) {
echo "<option value='$row_subbed_0[personnel_id]'>$row_subbed_0[last_name], $row_subbed_0[first_name]</option>";
}
echo "</SELECT>";
Now, my question is....can I re-use $result_subbed for each of the nine rows or do I need to need to do 9 separate database queries and run mysql_fetch_array on each of those?
I tried doing something like this for the second row but it doesn't work.
echo "<select name='subbed_1' onchange=\"reload3(this.form)\"><option value=''>Select one</option>";
while($row_subbed_1 = mysql_fetch_array($result_subbed)) {
echo "<option value='$row_subbed_1[personnel_id]'>$row_subbed_1[last_name], $row_subbed_1[first_name]</option>";
}
echo "</SELECT>";
It seems like there should be an efficient way to do this.
As always, any help is very much appreciated.
Thanks,
Scott