How can the PHP script be modified to dynamically reload the page with the selected IATACode appended to the URL for the prices query?

To dynamically reload the page with the selected IATACode appended to the URL for the prices query, you can use JavaScript to capture the selected value from a dropdown menu and then redirect the page with the selected value appended to the URL as a query parameter. This can be achieved by listening for a change event on the dropdown menu and then updating the window location with the selected value.

<?php
if(isset($_GET['IATACode'])){
  $selectedIATACode = $_GET['IATACode'];
  // perform the prices query with the selected IATACode
}

// HTML form with dropdown menu
echo '<form id="iatacodeForm">';
echo '<select name="IATACode" id="IATACode">';
echo '<option value="JFK">JFK</option>';
echo '<option value="LAX">LAX</option>';
echo '</select>';
echo '<input type="submit" value="Submit">';
echo '</form>';

// JavaScript to dynamically reload the page with selected IATACode
echo '<script>';
echo 'document.getElementById("IATACode").addEventListener("change", function() {';
echo '  var selectedIATACode = this.value;';
echo '  window.location.href = window.location.pathname + "?IATACode=" + selectedIATACode;';
echo '});';
echo '</script>';
?>