Hi there,
I'm building a website about animals.
There is a mySQL DB behind it.
There are 2 tables: 1 - species
2 - animals
Species could be: birds, fishes etc.
Animals would be: hawk, eagle etc, and orca, whale etc.
So every animal belongs to one of the species.
Anyway, there is an admin part to delete or edit animals or entire
species.
You get an overview of all the species, and behin it is a number of
how much animals there are in it.
I calculated them as following:
(Query to get species){
$species_name=$ query['name'];
$count_animals = mysql_query("SE LECT COUNT(*) FROM animals WHERE
sort_of_species =$species_name" );
$total_animals_ in_species = mysql_result($c ount_total_item s, 0);
echo $species_name." amount=".$total _animals_in_spe cies;
}
To make a long story short, for each positive result in the
"get-species-query" i run another one to count the animals inside.
is this heavy for the server/DB, is there a better way to do this?
Sorry for the long story, i hope it's clear...
Thanks in advance.
greetings knoakske
I'm building a website about animals.
There is a mySQL DB behind it.
There are 2 tables: 1 - species
2 - animals
Species could be: birds, fishes etc.
Animals would be: hawk, eagle etc, and orca, whale etc.
So every animal belongs to one of the species.
Anyway, there is an admin part to delete or edit animals or entire
species.
You get an overview of all the species, and behin it is a number of
how much animals there are in it.
I calculated them as following:
(Query to get species){
$species_name=$ query['name'];
$count_animals = mysql_query("SE LECT COUNT(*) FROM animals WHERE
sort_of_species =$species_name" );
$total_animals_ in_species = mysql_result($c ount_total_item s, 0);
echo $species_name." amount=".$total _animals_in_spe cies;
}
To make a long story short, for each positive result in the
"get-species-query" i run another one to count the animals inside.
is this heavy for the server/DB, is there a better way to do this?
Sorry for the long story, i hope it's clear...
Thanks in advance.
greetings knoakske
Comment