I have the following code to populate cities in a table.
$cities_query = "SELECT city_name FROM city_selection";
$cities_result = mysql_query($cities_query);
echo "<table>";
while ($row = mysql_fetch_assoc($cities_result))
{
echo "<tr>";
echo "<td>".$row['city_name'] . "</td>";
echo "</tr>";
}
echo "</table>";
Now I need to group every city by a region so I created the table called city_region_selection and added a Foreign key from the new column "region_id" in the city_selection table to region_id in the new table.
I’m now struggling to present this data in a nice html table using PHP.
Is it even possible to populate first a table row with region_name and then some subrows containing cities from that region? Please see this image for details:

You just have to do a little preprocessing:
Alternate Method with SQL focus
Help
Note that the
whilesyntax is just abridged. You would probably replace it with… for example
Once
regionsis built, simply do this: