0
我只想知道如何在这里添加数据类型?谷歌图表需要数据类型时,我使用此代码:使用PHP和MySQL的Google图表的数据类型
我从谷歌图表得到一个错误,它的数据类型需要定义...请帮助。谢谢!
while($r = mysql_fetch_assoc($query)) {
$google_JSON = "{cols: [";
$column = array_keys($r);
foreach($column as $key=>$value){
$google_JSON_cols[]="{id: '".$key."', label: '".$value."'}";
}
$google_JSON .= implode(",",$google_JSON_cols)."],rows: [";
$google_JSON_rows[] = "{c:[{v: '".$r['id']."'}, {v: ".$r['count']."}]}";
}
// you may need to change the above into a function that loops through rows, with $r['id'] etc, referring to the fields you want to inject..
//pass it into google charts data
echo $google_JSON.implode(",",$google_JSON_rows)."]}";
感谢Man,好吧..我会尝试在PHP中进行编码,即时消息在使用Perl中不是很好...实际上我不熟悉它。 – 2012-03-01 01:08:56