Thanks Andrew. It worked with the correction that you mentioned. It was the 
static data which is working. However, I want a JSON file similar to the 
above one to be generated from the data fetched from database. I am working 
with PHP and MYSQL. When i run a select query and generate the PHP file i 
observed that there are few things missing in the JSON file. Also guess may 
be because of that the graph was also not getting generated, instead a 
blank page was displayed.

*My PHP code to fetch data from db and generate a JSON file *
<?php
$cal_st_date = '2014-10-2';
$cal_end_date = '2014-10-9';
$gph_values = array();

include 'db.php';
$fetch_rows = mysql_query("SELECT 
cg.attach_doc_path,cg.start_date,cg.end_date,cg.coupon_upc,cg.coupon_type 
FROM CPNS_TESTING cg,CPNS_TESTED ct where cg.cpn_id=ct.coupon_id and 
ct.approved='Y' and ct.valid='T' and cg.end_date >= '$cal_st_date' group by 
cg.cpn_id");
$num_rows = mysql_num_rows($fetch_rows);
echo $num_rows;
while($row = mysql_fetch_array($fetch_rows))
{ 
$row_array['file']= $row['attach_doc_path'];
$row_array['upc'] = $row['coupon_upc'];
$row_array['Cpn_type'] = $row['coupon_type'];
 $start_date = $row['start_date'];
$str_start_date = strtotime($start_date);
$str_cal_start_date = strtotime($cal_st_date);
if($str_start_date >= $str_cal_start_date)
{
$arr_start_date = explode("-",$start_date);
$arr_start_date = 
$arr_start_date[0].",".$arr_start_date[1].",".$arr_start_date[2];
$row_array['start_date'] = $arr_start_date;
}
else
{
$arr_start_date = explode("-",$cal_st_date);
$arr_start_date = 
$arr_start_date[0].",".$arr_start_date[1].",".$arr_start_date[2];
$row_array['start_date'] = $arr_start_date;
 }
 $end_date = $row['end_date'];
$str_end_date = strtotime($end_date);
$str_cal_end_date = strtotime($cal_end_date); 
if($str_end_date >= $str_cal_end_date)
{
//$arr_end_date = $cal_end_date;
$arr_end_date = explode("-",$cal_end_date);
$arr_end_date = $arr_end_date[0].",".$arr_end_date[1].",".$arr_end_date[2];
$row_array['end_date'] = $arr_end_date;
}
else
{
//$arr_end_date = $end_date;
$arr_end_date = explode("-",$end_date);
$arr_end_date = $arr_end_date[0].",".$arr_end_date[1].",".$arr_end_date[2];
$row_array['end_date'] = $arr_end_date;
}
 $text = $upc . "-". $type;
 array_push($gph_values,$row_array);

}
//echo json_encode($gph_values); 
 $fp = fopen('C:\XAMP\htdocs\graph\sampleData.json', 'w+');
fwrite($fp, json_encode($gph_values));
fclose($fp);
 $string = file_get_contents("sampleData.json");
echo $string;
?>

JSON file got generated
[{"file":"welcome.txt","upc":"test","Cpn_type":"test","start_date":"2014,10,2","end_date":"2014,10,9"},
{"file":"Queries.txt","upc":"132","Cpn_type":"123","start_date":"2014,10,02","end_date":"2014,10,9"}]

In the above JSON file there is no ROWS and Columns mentioned.
Please assist in generating a proper JSON file.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to