2013-12-19 31 views
1

我正在使用php lib圖表顯示數據庫中的一些數據。當我在頁面的div元素中使用它時,會顯示圖形圖像。但我無法顯示其他頁面元素,如表單。如何在html表格中顯示PHPGraphLib圖表

date_default_timezone_set("Asia/Calcutta"); 
include("includes.php"); 
include('phpgraphlib.php'); 
session_start(); 
$graph = new PHPGraphLib(350,280); 
$data= array(); 
$Select_Query = "select level,sum(score) score,sum(total_time) total_time from 
user_score where user_id='2' group by level"; 
$result_query = mysql_query($Select_Query); 
$rows = mysql_num_rows($result_query); 

while($row=mysql_fetch_array($result_query)){ 
    $data[$row['level']] = $row['score']; 
    } 
$graph->setBackgroundColor("black"); 
$graph->addData($data); 
$graph->setBarColor('255,255,204'); 
$graph->setTitle('IQ Scores'); 
$graph->setTitleColor('yellow'); 
$graph->setupYAxis(12, 'yellow'); 
$graph->setupXAxis(20, 'yellow'); 
$graph->setGrid(false); 
$graph->setGradient('silver', 'gray'); 
$graph->s`enter code here`etBarOutlineColor('white'); 
$graph->setTextColor('white'); 
$graph->setDataPoints(true); 
$graph->setDataPointColor('yellow'); 
$graph->setLine(true); 
$graph->setLineColor('yellow'); 
$graph->createGraph(); 

然後我有一些html div和窗體。但是隻有圖形圖像顯示在瀏覽器上,而不是形式。如何解決它?

回答

2

您需要從單獨的PHP腳本生成圖形圖像,並使用img標記將其插入到您的頁面中。

將圖表創建代碼移動到另一個文件,如graph.php,然後在您的頁面中插入<img src="graph.php"/>

+0

非常感謝 – user1755949