The following is the start of the millionth non-functioning attempt, it does not even return distinct results:
<?php
require 'config.php';
$sqlcountryquery = "SELECT distinct country, region, towncity FROM input ORDER BY country, region, towncity";
$resultcountry = $mysqli->query($sqlcountryquery);
while ($rowcountry = $resultcountry-> fetch_assoc()){
echo"<option value=\"{$rowcountry['country']}\">";
echo $rowcountry['country'];
echo "</option>";
}
?>
I feel like I have been close before but gave up in frustration and don't have the code. My mindset at the moment is that I need to load the results of the query into a multidimensional array as:
COUNTRY -> REGION -> TOWNCITY
then use a while, if loop to build the first field and remove duplicate entries (instead of DISTINCT). then use jQuery and javascript to extract the rest of the values in the array as the parent field changes
First though I need to get that darn array figured out. Does it sound like I'm on the right track? How do I get that array working?