query("SELECT rd_countries.name AS 'country_name', rd_continents.name AS 'continent_name', country_code FROM rd_countries, rd_continents WHERE rd_countries.continent_id = rd_continents.id"); $countries = array(); while ($row = mysql_fetch_array($query)) { $countries[$row['1']][] = $row['0']; $countries[$row['1']][$row[0]][] = $row['2']; } ?>