<?php
    $con = mysqli_connect("localhost","root","root","iom_rdh");
    if (!$con) {
    die('Could not connect: ' . mysqli_error());
    }
	$sth = mysqli_query($con,"SELECT agegroup from duration");
    $rows = array();
    $rows['name'] = 'Age';
    while($r = mysqli_fetch_array($sth)) {
     $rows['data'][] = $r['agegroup'];
    }
    $sth = mysqli_query($con,"SELECT involuntary from duration");
    $rows1 = array();
    $rows1['name'] = 'Involuntary';
	$rows1['color'] = '#f37c2e';
    while($rr = mysqli_fetch_array($sth)) {
     $rows1['data'][] = $rr['involuntary'];
    }
	$sth = mysqli_query($con,"SELECT voluntary from duration");
    $rows2 = array();
    $rows2['name'] = 'Voluntary';
	$rows2['color'] = '#0033a1';
    while($rr = mysqli_fetch_array($sth)) {
     $rows2['data'][] = $rr['voluntary'];
    }
	$result = array();
    array_push($result,$rows);
    array_push($result,$rows1);
	array_push($result,$rows2);
    print json_encode($result, JSON_NUMERIC_CHECK);
    mysqli_close($con);
    ?>