http://www.highcharts.com/stock/demo/basic-line 我對json.php代碼:Highchart基本線
<?php
header("content-type: application/json");
define('HOST', 'localhost');
define('USER', 'root');
define('PASSWORD', 'Super_Password');
define('NAME_BD', 'bd');
$connect = mysql_connect(HOST, USER, PASSWORD)
or die("error"
.mysql_error());
// print ("no error");
mysql_select_db(NAME_BD, $connect)
or die ("error"
.mysql_error());
$result = mysql_query("SELECT UNIX_TIMESTAMP(`Time`) * 1000 as datetime, `Current A` as A FROM `TT`")
or die ("error".mysql_error());
// echo "all good";
while ($row = mysql_fetch_array($result)) {
$data[] = $row['datetime'];
$datab[] = $row['A'];
}
echo '?(' . "\n" . '['. "\n";
$count = count($data);
for ($i=0; $i<$count; $i++)
{
echo '['. str_replace('"', "", json_encode($data[$i], JSON_HEX_APOS)) . ',' . str_replace('"', "", json_encode($datab[$i], JSON$
}
//echo '('. json_encode(join($data, ',')) . ')';
echo ']);';
?>
但它不工作:當我刷新我的網頁我看不到圖表
控制檯中是否有錯誤? – nerdlyist