Hi all,
I\'m having trouble getting the results of a mysql query in php into jpgraph. Current code looks like this:
<?php
header(\"Content-type: image/gif\");
include (\"./media/graph-plugins/jpgraph.php\");
include (\"./media/graph-plugins/jpgraph_pie.php\");
include (\"./media/graph-plugins/jpgraph_pie3d.php\");
$query2 =(\"SELECT count(*) FROM demographic GROUP BY browser\");
$result2 = mysql_query($query2);
// Data from database:
$data = $result2;
// Create the Pie Graph.
$graph = new PieGraph(350,200,\"pieex1\");
// Set A title for the plot
$graph->title->Set(\"breakdown: browser usage\");
$graph->title->SetFont(FF_VERDANA,FS_NORMAL,12);
$graph->title->SetColor(\"black\");
$graph->legend->Pos(0.05,0.2);
$graph->legend->SetShadow(false);
$graph->legend->SetFillColor(\"white\");
// Create 3D pie plot
$p1 = new PiePlot3d($data);
$p1->SetCenter(0.4);
$p1->SetAngle(50);
$p1->SetFont(FF_TIMES,FS_NORMAL,14);
$query =(\"SELECT browser FROM demographic GROUP BY browser\");
$result = mysql_query($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
while( list ($key, $value) = each($row) )
{
echo \"\\"\" . $value . \"\\",\";
}
}
$p1->SetLegends(array(\"msie 4\",\"msie 5\",\"msie 5.01\",\"msie 5.5\", \"msie 6\"));
$graph->Add($p1);
$graph->Stroke();
?>
With the problem lying here:
$query2 =(\"SELECT count(*) FROM demographic GROUP BY browser\");
$result2 = mysql_query($query2);
// Data from database:
$data = $result2;
Any thoughts? Thanks in advance...