My aim is to create a dynamic webpage that returns all of the records in a table meeting a given criteria and uses them to populate a webform. The user can then make changes as they wish and update the entire table with a single button press.
In the example below I'd like to list all the events, the start time will appear in an editable text box and when I press submit it should update all the values.
I've created a mock-up below:
$query = "SELECT * FROM Events";
$result = mysqli_query( $dbc, $query ) ;
if ( mysqli_num_rows( $result ) > 0 )
{
echo '<form action="update_events.php" method="post">>';
echo '<table><tr>';
while ( $row = mysqli_fetch_array( $result, MYSQLI_ASSOC ))
{
echo '<td>' . $row['Event_Name'] .' </td>'.
'<td>' . $row['Event_Date'] .'</td>'.
'<td><input name="'. $row['Event_ID'] .'" type="text" value="'$row['Event_Start_Time'] .'"></td>';
echo '</tr>';
}
echo '</table>';
echo ' <input type="submit" value="Submit"></form>';
mysqli_close( $dbc ) ;
}
else
{
echo '<p>There are currently no events.</p>' ;
}
I cannot figure our how to get the processing on the update_events.php to work, any help would be appreciated.
foreach(????){
$sql = "UPDATE Events SET Event_Start='$Event_Start' WHERE id='$Event_ID'";
mysqli_query($dbc, $sql)
}