0

以下のコードはデータを JSON 形式で表示しません。どこが間違っているのかわかりません。以下のコードを使用して、Google チャートを生成するためのデータを表示する必要があります。

<?php


include ("db/Config.php"); 

$query = mysql_query('select b.ifbank as Bank,sum(a.amt) as Amount from mtrans a JOIN ifsc b on b.ifscd=a.ifsc and orgdate between "20121001" and "20121031" group by bank');

$table = array();
$table['cols'] = array(

    array('label' => 'Bank', 'type' => 'string'),
    array('label' => 'Amount', 'type' => 'number')
);

$rows = array();
while($r = mysql_fetch_assoc($query)) {
    $temp = array();
    $temp[] = array('v' => $r['Bank']);
    $temp[] = array('v' => (int) $r['Amount']); // typecast all numbers to the appropriate type (int or float) as needed - otherwise they are input as strings

    $rows[] = array('c' => $temp);
}


$table['rows'] = $rows;

$jsonTable = json_encode($table);


header('Cache-Control: no-cache, must-revalidate');

header('Content-type: application/json');

echo $jsonTable;


?>
4

0 に答える 0