The PHP coding would be outside of the form completely. When the form submits, it sends the key=>value pairs to the php page to process the results and update the database. All of that is separate from the form itself.
Another note, your table here:
student# | A1 |
| box with grade| submit |
| box with grade| submit |
… | … | …|
It looks like you are planning to have multiple submit buttons, one for each line. If you want to do that, then you will want to have separate forms for each student. The buttons don’t know what to do either than to submit all of the inputs for the form at the same time. If you want to submit each student’s grades individually, that would certainly simplify the naming issue. Example:
<table>
<tr><td><form><textbox><submit></form></td></tr>
<tr><td><form><textbox><submit></form></td></tr>
<tr><td><form><textbox><submit></form></td></tr>
<tr><td><form><textbox><submit></form></td></tr>
</table>
Obviously this is not valid HTML coding, merely to demonstrate the point.
In this style, each form tracks only one line of the table, so the name of the text box in the next line is unknown to the form. If you click submit, you will only be submitting the one student’s grade for updating.
Now my example doesn’t break the rows into the cells as you did, so here’s something to consider:
<table>
<form><tr><td>name</td><td><textbox></td><td><submit></td></tr></form>
<form><tr><td>name</td><td><textbox></td><td><submit></td></tr></form>
<form><tr><td>name</td><td><textbox></td><td><submit></td></tr></form>
<form><tr><td>name</td><td><textbox></td><td><submit></td></tr></form>
</table>
Now this is not good HTML, but it will accomplish the goal. You might consider either creating your display in one <td> using CSS to format, or break each row into its own table so that the HTML is still valid, i.e.
<form><table><tr><td>name</td><td><textbox></td><td><submit></td></tr></table></form>
<form><table><tr><td>name</td><td><textbox></td><td><submit></td></tr></table></form>
<form><table><tr><td>name</td><td><textbox></td><td><submit></td></tr></table></form>
<form><table><tr><td>name</td><td><textbox></td><td><submit></td></tr></table></form>
This might be too bulky for your tastes or it might be fine. That part’s up to you.