2015-10-19 75 views
0

我正在使用AmCharts創建折線圖。所以我試圖從我的mysql數據庫分配數據到圖表,我使用它。在AmCharts中顯示來自mysql的數據

AmCharts.makeChart("chartdiv", { 
    "type": "serial", 
    "dataLoader": { 
     "url": "data.php", 
     "format": "json" 
    }, 
    // we'll skip the rest of the config for now // 
}); 

data.php文件有PHP腳本連接到MySQL服務器,加載數據並以JSON格式輸出數據。

但我不能(使用後ID)

+0

請正確格式化代碼。缺少引號.. –

+0

AmCharts.makeChart(「chartdiv」,{ 「type」:「serial」, 「dataLoader」:{ 「url」:「data.php」, 「format」:「json」 }, //我們現在跳過配置的其餘部分 // .. }); – sami

回答

0

我會改變我的選擇子句中的SQL傳遞變量(ID)的data.php文件,以查詢特定的崗位,做:

WHERE id = 1 

我認爲應該這樣做。但也有可能是JSON做得太的方式,你也許可以通過一個ID的網址:

AmCharts.makeChart("chartdiv", { 
"type": "serial", 
"dataLoader": { 
"url": "data.php?ID=1", 
    "format": "json" 
}, 
// we'll skip the rest of the config for now 
// .. 
}); 

但是請向PHP或JSON大師。