Good day all:
I'm trying to create a graph using data from mysql on the jpgraph platform. I've been experiencing difficulties with an error 15009 and cannot seem to address the error --lots of reading on the net concerning this error has yield nothing. I'm hoping that someone here is familar with this issue. Here is my code:
<?php
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_pie.php");
include_once ("jpgraph/jpgraph_pie3d.php");
$connect = mysql_connect("localhost","jjdjjd",",,,,,");
$sql = "SELECT DISTINCT servicearea FROM additional_cars";
$RESULT = mysql_db_query("shop","$sql",$connect);
$records = mysql_num_rows( $RESULT); // number of unique services
for($i=0;$i<$records;$i++) // for every unique services read the next lines
{
$row = mysql_fetch_row($RESULT);
$servicearea = $row[0];
$sql_2 = "SELECT servicearea FROM additional_cars WHERE servicearea = '$servicearea'";
$RESULT_2 = mysql_db_query("shop","$sql_2",$connect);
$records_2 = mysql_num_rows( $RESULT_2);
//echo $records_2; // number of unique services
$row_2 = mysql_fetch_row($RESULT_2);
$service_used[] = $row_2[0];
}
$datavalue = array_merge($service_used);
$datax = $datavalue;
$datay = $datavalue;
$graph = new PieGraph(410, 310,"auto");
$graph->SetShadow();
$graph->title->Set("Top three services rendered this week");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$p1 = new PiePlot3D($datax);
$p1->SetSize(.3);
$p1->SetCenter(0.45);
$p1->SetStartAngle(300);
$p1->SetAngle(45);
$p1->SetTheme('earth');
$p1->value->SetFont(FF_FONT1,FS_BOLD);
$p1->SetLabelType(PIE_VALUE_PER);
$legends = array($datay);
$p1->SetLegends($legends);
$a = array_search(max($datax),$datax); //Find the position of maixum value.
$p1->ExplodeSlice($a);
$graph->Add($p1);
$graph->Stroke();
?>
The intent of the above code is to pull data from a table column that has different values --specifically, different services being rendered at a shop. The first sql statement queries for all services from the column and then uses the variable $servicearea to query in the second sql statement which determines how many time each unique service is being performed.
I want to graph this in a pie chart, to thus know which of all the services area rendered the most --in percentage.
I trust that someone here is familiar with this and can provide some insight!
Thanks,
Mossa