I want to know how many children a particular she goat has given birth to. Below is my code which is not giving me what i want so somebody should help me out, please.
<?php
include("db.php");
$query = "SELECT mothername, COUNT(goatid) FROM goats GROUP BY mothername";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "There are ". $row['COUNT(goatid)'] ." ". $row['mothername'] ." Children Goat(s).";
echo "<br/>";
}
?>
I have finally gotten the logic. here is it
include("db.php");
$query = "SELECT mothername, COUNT(goatid) FROM goats GROUP BY mothername";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo $row['mothername'] ." has ". $row['COUNT(goatid)'] ." Kid(s).";
echo "<br/>";
}
?>