我正在尝试在Highchart(行)中显示此查询输出。我想知道如何将这个MySQL循环输入Highchart。
<?php
$qu = "SELECT *,COUNT(url) FROM clicks WHERE url='aaaa' GROUP BY date";
$result = mysql_query($qu) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$hits = $row['COUNT(url)'];
$date = $row['date'];
}?>
答案 0 :(得分:1)
也许这会给你一些想法:
$label = array();
while($row = mysql_fetch_array($result))
{
$label[] = $row["date"];
$data_count[] = (float)$row["COUNT(url)"];
}
$series = array();
$series[] = array("name"=> 'total', "color" => "#4572a7", "data" => $data_count);
$data = array();
$data["chart"]["renderTo"] = "report";
$data["chart"]["defaultSeriesType"] = "column";
$data["title"]["text"] = "Some Title Here";
$data["series"] = $series;
$data["xAxis"]["categories"] = $label;
$data["yAxis"]["allowDecimals"] = true;
header('Content-Type: application/json; charset: utf-8;');
echo json_encode($data);