<?php
$start_date=$_POST['start_date'];
$end_date=$_POST['end_date'];

include 'config.php';
$sth = mysqli_query($con,"SELECT agegroup from duration where registration_date between '$start_date' and '$end_date' group by agegroup order by agegroup");
$rows = array();
$rows['name'] = 'Age';
while($r = mysqli_fetch_array($sth)) {
$rows['data'][] = $r['agegroup'];
}
$sth = mysqli_query($con,"SELECT agegroup,coalesce(sum(voluntary+involuntary),0) as involuntary from duration where registration_date between '$start_date' and '$end_date' group by agegroup order by agegroup");
$rows1 = array();
$rows1['name'] = 'Duration';
$rows1['color'] = '#0033a1';
while($rr = mysqli_fetch_array($sth)) {
$rows1['data'][] = $rr['involuntary'];
}
$result = array();
array_push($result,$rows);
array_push($result,$rows1);
print json_encode($result, JSON_NUMERIC_CHECK);
mysqli_close($con);
?>