displaying countries with all regions from mysql

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
adrianuk29
Forum Newbie
Posts: 1
Joined: Fri Feb 20, 2004 1:57 am

displaying countries with all regions from mysql

Post by adrianuk29 »

I need a bit of help, if anyone can help me. I have been scratching my head for the last few hours. I am trying to list the countries with the regions from my database. At present I am getting the country and only one region. I need to display all the regions. Here is the output I recieve form my php page.

Australia
Queensland (2)

Canary Islands
Tenerife (5)

Croatia
Dalmatia (1)

In Canary Islands I have at least another two regions that should be displayed at the moment it is only showing tenerife.

Here is my code, I hope someone can help me. Many thanks.

$query = "SELECT property_location,property_region,
count(property_region) AS cnt
FROM property_data GROUP BY property_location";

$res = mysql_query($query) or die(mysql_error());
if(mysql_num_rows($res) > 0) {
while($row=mysql_fetch_array($res)) { ?>
<font face=arial size=2><? echo $row['property_location']; ?></a>&nbsp;&nbsp;&nbsp;<br><? echo $row['property_region']; ?> (<? echo $row['cnt']; ?>)</font><br>
<br>
<? }
}
else {
echo "Nothing found"
} ?>
Post Reply