i am running PHP Version 5.2.9, i want to create a barchart from data in mysql. i got this sumple and tried running it. am having a bit if trouble with json_encode(). i have an array that has numbers and strings but the numbers get printed back as strings. how do i make sure the numbers are printed back as nunmbers. the code i have is below. I ddnt update because the server i want to to use also uses php 5.2.* (000webhost)
$query = mysql_query("SELECT month, wordpress, codeigniter, highcharts FROM project_requests");
$category = array();
$category['name'] = 'Month';
$series1 = array();
$series1['name'] = 'Wordpress';
$series2 = array();
$series2['name'] = 'CodeIgniter';
$series3 = array();
$series3['name'] = 'Highcharts';
while($row = mysql_fetch_assoc($query)) {
$category['data'][] = $row['month'];
$series1['data'][] = $row['wordpress'];
$series2['data'][] = $row['codeigniter'];
$series3['data'][] = $row['highcharts'];
}
$result = array();
array_push($result,$category);
array_push($result,$series1);
array_push($result,$series2);
array_push($result,$series3);
print json_encode($result, JSON_NUMERIC_CHECK);
mysql_close($con);
the above code says json_encode requires 1 parameter and 2 are given
print json_encode($result, JSON_NUMERIC_CHECK);
, when i remove the second parameter to get
print json_encode($result);
, the graph i want renders but no bars as the numbers are returned as strings.