Open Rayner061 opened 5 years ago
include_once('connection.php');
$diseaseselection = $_REQUEST['diseaseselection'];
if(isset($diseaseselection)){
$result = mysqli_query($con, "SELECT disease,age,SUM(CASE WHEN gender = 'm' THEN 1 ELSE 0 END) AS `totalM`, SUM(CASE WHEN gender = 'f' THEN 1 ELSE 0 END) AS `totalF` FROM mdr where disease = '$diseaseselection' GROUP BY disease , age");
$chart_data = '';
while($row = mysqli_fetch_array($result))
{
$tabx[]=$row['totalF'];
$taby[]=$row['totalM'];
}
$tableau=array_combine($tabx,$taby);
foreach($tableau as $key=>$value){
$string[]=array('totalF'=>$key,'totalM'=>$value);
}
echo json_encode($string);
}
Here is my sample PHP