如何在html表单中显示PHPGraphLib图

时间:2013-12-19 09:43:33

标签: php graph phpgraphlib

我使用php lib graph来显示数据库中的一些数据。当我在页面的div元素中使用它时,将显示图形图像。但我无法显示其他页面元素,如表单。

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和形式。但是只有图形图像显示在浏览器上而不是表单上。如何解决?

1 个答案:

答案 0 :(得分:2)

您需要从单独的PHP脚本生成图形图像,并将其插入带有img标记的页面中。

将图表创建代码移至另一个文件,例如graph.php,然后在页面中插入<img src="graph.php"/>