I have created a database to store results in a competition along witha php generated web-page that lists all the competitors followed by a textbox in which to record their score.
When I press the submit button I want it to update all of the rows in the table.
I'm new to php and mySQL, I can do it for one of them at a time but I don't want them to have to press 30+ individual submit buttons to handle each row.
The following code generates the form:
  <?php
   $field_event_id = $sports_day_id = "";
   if ( $_SERVER[ 'REQUEST_METHOD' ] == 'POST' )
    $field_event_id = $_POST["field_event"];
    $sports_day_id = $_POST["sportsday"];
    $query = "SELECT * FROM student JOIN participants ON student.student_ID = participants.student_ID WHERE `Field_Event_ID`= $field_event_id";
    $result = mysqli_query( $dbc, $query ) ; 
     echo '<body>';
if ( mysqli_num_rows( $result ) > 0 )
{
    echo'<header> <h1> Please enter the results below </h1> </header>';
      echo '<table align="center" border="1" cellpadding="10px" bgcolor="#DCF8FE">
        <tr>
            <th>Forename</th>
            <th>Surname</th>
            <th>Year Group</th>
            <th>Score</th>
        </tr>
<tr>';
     while ( $row = mysqli_fetch_array( $result, MYSQLI_ASSOC ))
    {
        echo '<form action="Add_Scores_Field_Event_Register.php" method="post">
            <td> <strong>' . $row['Forename'] .'</strong><br> </td>
            <td> <strong>' . $row['Surname'] .'</strong><br> </td>
            <td> <strong>' . $row['Year_Group'] .'</strong><br> </td>
            <td> <strong>   <input type="text" name="notes_input"> </strong><br> </td>           
            </tr>
            </form>';
     }
     echo '</table>';
         echo '<p><input type="submit" value="Enter scores" ></p>';
}
else 
{ 
    echo '<p>There are currently no students in this event.</p>' ; 
}
{
     # Close database connection.
     mysqli_close( $dbc ) ; 
}
# close body section.
echo '</body>';
# close HTML section.
echo '</html>';
mysqli_close($dbc);
?>
 
    