I am making a dynamic PHP form that interacts with a mySQL database for entering the scores of students on different assignments. So far I have successfully connected to the database and accessed the necessary data. The following code displays for each student first, their name, and then an empty text input box where the user enters the score said student earned on the assignment.
<?php if(isset($_POST["beginScoring"]) || isset($_POST['submitScores'])){
$result = $connection->query("SELECT id, firstname, lastname FROM student ORDER BY lastname");
if(!$result)
{
echo "Query Failure";
}
else
{
$foo = array();
$c = 0;
echo "<tr><td>Last Name</td><td>First Name</td><td>Points Earned</td></tr>";
while ($row = $result->fetch_assoc())
{
echo "<tr><td>$row[lastname]</td><td>$row[firstname]</td>";
?>
<td><input type="text" size=8 name="" id="" value=""/></td></tr> <!-- I can maybe use an array to store scores . . . -->
<?php
}
}
?>
The thing I am having issues with is how do I name the text input. Since there are going to be an undetermined amount of text boxes, I can't use a single static name for the input item, right? What would be a good way to name the text boxes so that I can easily access them using the POST array?