I have a program where in the first file(distribution.php) teachers can be selected from multiple dropdownboxes (called teacher_0, teacher_1, teacher_2 etc...). No problem so far, but when I submit, in the second file(selected.php) I want to show the selected teachers. This doesn't seem to work... please help
distribution.php
...
<form action="selected.php" method=post>
<table>
<?for ($x=0;$x<20;$x++){
$query2 = "select * from docentes order by doc_name";
$result2 = mysql_query($query2);
$count2 = mysql_numrows($result2);
$teacher = "teacher_".$x;
?>
<tr>
<td>
<select name=<? echo $teacher;?>>
<option>-------Select-------</option>
<?
for($y=0;$y<$count2;$y++){
$doc_name = mysql_result($result2, $y,"doc_name");
$doc_id = mysql_result ($result2, $y, "doc_id");
echo"<option value='$doc_id'>$doc_name</option>";
}
?>
</select>
</td>
</tr>
<?}?>
</table>
<input type=submit value=submit>
</form>
...
selected.php
...
<?
for($i=0;$i<20;$i++){
$selectedteacher='$teacher_'.$i;
$selectedteacher= addslashes($selectedteacher);
$query = "select * from docentes where doc_id='$selectedteacher'";
$result = mysql_query($query);
$count = mysql_numrows($result);
$doc_name = mysql_result($result, 0, "doc_name");
echo "this is the selected docent $i:";
echo "<input type=text value='$doc_name'><br>";
}
?>