Closed (fixed)
Project:
PHP variables
Version:
5.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Task
Assigned:
Reporter:
Created:
7 Oct 2008 at 09:26 UTC
Updated:
27 Oct 2008 at 03:26 UTC
please help me im dying on it
//Include the code
include("phplot-5.0.5/phplot.php");
//Get the data from database
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$dbname="simpati_unkhair";
$dblink=mysql_connect($dbhost,$dbuser,$dbpass);
$sql=mysql_db_query($dbname, "select * from sale");
$num=mysql_num_rows($sql); //menentukan xmax, bisa juga ditambahkan cari ymax
while(list($bulan,$jumlah)=mysql_fetch_array($sql))
{
$data[] =array("$bulan",$jumlah);
}
//Define the object
$graph = new PHPlot(700,400);
$graph->SetPlotAreaWorld(0,0,$num,60); // xmax ->$num
$graph->SetTitle("Contoh Grafik Batang");
$graph->SetVertTickPosition('plotleft');
$graph->SetSkipBottomTick(1);
$graph->SetDataValues($data); //data berupa array
$graph->SetDrawYGrid(1);
$graph->SetPlotType('bars');
$graph->SetDrawDataLabels('1');
$graph->SetLabelScalePosition('1');
$graph->SetDataColors(array("blue"));
$graph->SetMarginsPixels(50,50,50,50);
//Draw it
$graph->DrawGraph();
mysql_close($dblink);
error like this :
Fatal error: Cannot use object of type stdClass as array in C:\Program Files\xampp\htdocs\simpati_unkhair\PEJABAT\REKTORAT\file\file.grafikmhsperfak.php on line 16
Comments
Comment #1
nedjoThis question is not related to PHP variables module or any other module. Pls repost as a forum topic in the "support" forum.