I have a table with 4 columns (name, proof1, proof2, dummy). Suppose you are a teacher, and you want to post student grades. I'll give you the following:
// $l representará o número de linhas que existem
$l = -1;
// $inst2 carrega: SELECT nome, prova1, prova2, simulado FROM alunos
while($dado = mysqli_fetch_row($inst2)) {
$l+=1;
$dados[] = $dado;
}
for ($x=0; $x<=$l; $x++) {
echo "<tr>";
for ($y=0; $y<=3; $y++) {
if ($y==0) {
echo "<td>".$dados[$x][$y]."</td>";
} else {
echo "<td><input type=\"text\" value=\"".$dados[$x][$y]."\" size=\"6\"></td>";
}
}
}
echo "</tr>";
echo "</table>
In other words, the table notes in which there are no registered values (they are null) will have a input
for the teacher to insert the student's note.
My problem is: I want to have a button so that after the teacher inserts the notes he clicks on them and they are saved in the database.
I even thought of doing this: put the table that appears on the screen inside a form, and put in inputs text
a name using the variables $x
and $y
. And add a column with an id for each row ( auto_increment
). However, I could not move forward. Even though I believe there is a better way to do that.
PS: I prefer your help using procedural. Thanks!