I am trying to plot bar graph using chart.js and from mssql database.I am able to retrieve data from the database in array.I have used following code,
<?php
$serverName = "PC";
$uid = "sa";
$pwd = "PC#1234";
$databaseName = "climate";
$dsn = "sql";
$conn= odbc_connect ($dsn ,$uid ,$pwd);
if(!$conn){
echo('Connection Failed');
}
$sql="select convert(nvarchar(100), DVCDTxp_Datetime,106) )";
$rs=odbc_exec($conn,$sql);
if (!$rs){
exit("Error in SQL");
}
echo odbc_result_all($rs);
$response = array();
for($i=1;$i<= odbc_num_rows($rs);$i++){
$row = odbc_fetch_array($rs,$);
$response[] = $row;
}
?>
I am getting following output,
DATE AVG_VAL
06 Jun 2015 5.466593
08 Jun 2015 1.774121
09 Jun 2015 .729223
11 Jun 2015 3.329457
12 Jun 2015 2.344660
I want the following output ,
DATE=["06 Jun 2015","08 Jun 2015","09 Jun 2015","11 Jun 2015","12 Jun 2015"]
VALUE=["5.466593","1.774121",".729223","3.329457","2.344660"]