Forum Moderators: coopster
while($row = mysql_fetch_array($result)) {
echo "There are ".$row['COUNT(name)']." ".$row[$var]." "."TB"." "."patient(s)." "."from"." ".$row[$date1]." "."to"." ".$row[$date2];
echo "<br />";
}
?>
>>>$query = "SELECT $var, COUNT(name) FROM register WHERE dateReg >= '$date1' and dateReg <= '$date2' GROUP BY $var";
>>>echo "There are ".$row['COUNT(name)']." ".$row[$var]." "."TB"." "."patient(s)." "."from"." ".$row[$date1]." "."to"." ".$row[$date2];
To the following, respectively:
$query = "SELECT $var,COUNT(name) as num_name FROM register WHERE dateReg >= '$date1' and dateReg <= '$date2' GROUP BY $var";
echo "There are ".$row['num_name']." ".$row[var]." TB patient(s) from ".$row[date1]." to ".$row[date2];
This should work now. Good luck!
eelix
eelix