PHP MySQL在单个表中计算多个列

I'm trying to count different columns in a single table and store them as variables in PHP, I don't think I should be doing it this way I don't think:

$dog_count = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM animals WHERE animal='dog'"));
$cat_count = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM animals WHERE animal='cat'"));
$parrot_count...

I'm thinking there is probably a better way to count statistics. Any advice?

Thanks :)

You could get all the aminals and their respective counts in one query:

SELECT animal, COUNT(*) AS AnimalCount
    FROM animals
    GROUP BY animal