<?php
include("top.html");
include("adventure_shared.php");
?>

    <p>Choose characteristics a developing nation you'd like to visit.</p>

    <form action="adventure_recommendations.php" method="get">
      <div>
        <h2>Which continent and language(s) do you prefer?</h2>

      <select name="continent" size="5">
        <?php
        $query = "SELECT DISTINCT continent FROM Countries ORDER BY continent";
        get_and_print_options($query, "continent");
        ?>
      </select>

      <select name="languages[]" size="5" multiple="multiple">
        <?php
        $query = "SELECT DISTINCT language
                  FROM CountriesLanguages
                  WHERE official = 'T'
                  ORDER BY language";
        get_and_print_options($query, "language");
        ?>
      </select>
    </div>

    <div>
      <input type="submit" value="Submit" />
    </div>
    </form>
  </body>
</html>

<?php
function get_and_print_options($query, $column) {
  $results = perform_query($query);
  while ($row = mysql_fetch_array($results)) {
    $choice = $row[$column];
    ?>
    <option value="<?= $choice ?>"><?= $choice ?></option>
    <?php
  }
}
?>
