avraamG13 Posted June 2, 2009 Share Posted June 2, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/160564-solved-count-the-rows-and-show-total/ Share on other sites More sharing options...
Alex Posted June 2, 2009 Share Posted June 2, 2009 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 />"; } Quote Link to comment https://forums.phpfreaks.com/topic/160564-solved-count-the-rows-and-show-total/#findComment-847400 Share on other sites More sharing options...
Ken2k7 Posted June 2, 2009 Share Posted June 2, 2009 Not enough information, but like this probably - SELECT COUNT(country) AS count FROM tablename GROUP BY country; Quote Link to comment https://forums.phpfreaks.com/topic/160564-solved-count-the-rows-and-show-total/#findComment-847401 Share on other sites More sharing options...
avraamG13 Posted June 2, 2009 Author Share Posted June 2, 2009 Thank you very much, just what i was looking for ... Thank you again and sorry for my english Quote Link to comment https://forums.phpfreaks.com/topic/160564-solved-count-the-rows-and-show-total/#findComment-847413 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.