这是我的代码:
<?php
//Set content-type header
header("Content-type: image/png");
//Include phpMyGraph5.0.php
include_once('phpMyGraph5.0.php');
include("koneksi.php");
//Set config directives
$cfg['title'] = 'Example graph';
$cfg['width'] = 500;
$cfg['height'] = 250;
//Set data
$query="select col1, col2 from tab1 where sub_project = 'sometext'";
$result=mysql_query($query);
$row = mysql_fetch_assoc($result);
$data = array(
$row['col1'] => $row['col2'],
);
//Create phpMyGraph instance
$graph = new phpMyGraph();
//Parse
$graph->parseVerticalColumnGraph($data, $cfg);
?>
在我的例子中,数据 incol1
是一个文本,而 incol2
是一个数字。但是使用该代码,该图仅显示第一行值。同时来自数据库的值不止一个值。