Jump to content

[SOLVED] count the rows and show total...


avraamG13

Recommended Posts

Hello,

 

lets say i have a table (countrys) with some countrys... UK , USA, Italy ...

 

What i want, is a way lets say to show the country (UK) and next how many rows i have total with country UK, and this it will continue with the next country

 

Example:

UK - 10

USA - 1

Italy - 7

 

Any code examples how i can do this please??

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/160564-solved-count-the-rows-and-show-total/
Share on other sites

Edit:

 

$query = "SELECT country, COUNT(country) FROM contries GROUP BY country"; 

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){
echo $row['country'] . ' - ' . $row['COUNT(country)'];
echo "<br />";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.