How can PHP be used to create a complex reservation form with dynamic table selection?

To create a complex reservation form with dynamic table selection using PHP, you can use JavaScript to dynamically update the available tables based on the user's selection. You can store the table availability in a database and use PHP to fetch and display the available tables in real-time as the user interacts with the form.

<?php
// Assume $availableTables is an array of available tables fetched from the database
$availableTables = ['Table 1', 'Table 2', 'Table 3', 'Table 4'];

echo '<select name="table">';
foreach ($availableTables as $table) {
    echo '<option value="' . $table . '">' . $table . '</option>';
}
echo '</select>';
?>