Help with an array of pliiz. There is a vote_teach
table
id int(3) teach int(3) ocenka int(1)
The essence of this. Students are taught by teachers; their number can be 2-3-4-5 and so on. 2 times a year, students evaluate them. I need to make a mold. Need to choose the number of teachers. (For example, selects Digit 5 - gets 5 drop-down select menus). I can do on a fixed number of such forms, without choosing a quantity. It turns out the following algorithm. For each teacher, 2 fields - 1 from the database displays Fio, 2 - point. So, if I do for 3 teachers - 6 fields - 6 variables, I enter in the database as follows:
$result = mysql_query ("INSERT INTO vote VALUES ('$teach1','$teach1v')"); $result2 = mysql_query ("INSERT INTO vote VALUES ('$teach2','$teach2v')"); $result3 = mysql_query ("INSERT INTO vote VALUES ('$teach3','$teach3v')");
Where $ teach1 is the teacher's id, $ teach1v is the teacher's assessment. Question. Is it possible to do this in an associative array? And How? Type if I display the list like this:
for($i=1; $i<=$count_of_teacher; $i++) {echo '<select name="teach1">'; <?php $result = mysql_query("SELECT id,teach_fam, teach_name FROM teachers"); $myrow = mysql_fetch_array($result2); do { printf ("<option value='%s'>%s %s</option>",$myrow['id'],$myrow["teach_fam"],$myrow["teach_name"]);} while ($myrow = mysql_fetch_array($result)); ?> echo '</select>';}
Here I understood that there will be 5 drop-down lists. And how to put them in the database as well in the loop? As if in an array of this kind: teach [id] [rating] .