1
我想用GD庫使用PHP來顯示我的表在我的管理面板.. 我得到的日期從我的數據庫,但是當我使用任何庫顯示此結果線圖也沒有工作&它沒有顯示任何錯誤。我不明白我做錯了什麼? 任何人都可以幫助我嗎?如何使用php在我的管理面板中繪製統計線圖?
<?php
include ("../setting.php");
include("../classes/phpgraphlib.php");
$result = mysql_query("SELECT DATE_FORMAT(log_date, '%Y-%m-%d') as Date,count(*) as Count FROM log
where operation_type='Add' and user_id='82' and faculty_code='0' group by log_date order by log_date") or die(mysql_error());
$MultiDimArray = array();
$data = array();
while($row = mysql_fetch_array($result , MYSQL_BOTH))
{
$MultiDimArray[] = array ('Date' => $row['Date'], 'Count' => $row['Count']);
}
foreach($MultiDimArray as $value)
{
if (!array_key_exists($value['Date'], $data)) {
$data[$value['Date']] = $value['Count'];
}
else{ $data[$value['Date']] += (string)$value['Count'];}
}
$data = array_map('strval', $data);
$graph = new PHPGraphLib(400,300);
$graph->addData($data);
$graph->setTitle("Site Statistics");
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(true);
$graph->setDataPointColor("maroon");
$graph->setDatadata(true);
$graph->setDataValueColor("maroon");
$graph->setGoalLine(.0025);
$graph->setGoalLineColor("red");
$graph->setXdataHorizontal(true);
$graph->createGraph();
?> `
$數據陣列的輸出是這樣的:
array'2013-05-13' => string '7' (length=1)'2013-05-15' => string '3' (length=1)'2013-05-16' => string '5' (length=1)'2013-05-18' => string '8' (length=1)'2013-05-19' => string '2' (length=1)'2013-05-21' => string '2' (length=1)'2013-05-22' => string '10' (length=2)'2013-05-23' => string '2' (length=1)'2013-05-25' => string '1' (length=1)'2013-05-26' => string '8' (length=1)'2013-05-27' => string '19' (length=2)'2013-05-28' => string '7' (length=1)'2013-05-29' => string '3' (length=1)'2013-06-02' => string '11' (length=2)'2013-06-03' => string '2' (length=1)'2013-06-04' => string '7' (length=1)'2013-06-05' => string '3' (length=1)'2013-06-06' => string '2' (length=1)'2013-06-09' => string '15' (length=2)'2013-06-10' => string '5' (length=1)'2013-06-11' => string '1' (length=1)'2013-06-12' => string '3' (length=1)'2013-06-15' => string '10' (length=2)'2013-06-16' => string '3' (length=1)'2013-06-19' => string '2' (length=1)
考慮標記,並在標題提的GD庫。 – Jonast92
啓用錯誤報告或查看您的服務器日誌。 – str