Hello.
I am trying to connect my MYSQL Database to my JpGraph but it is not working.
Any help is appriciated. Here is my conde.
<?php
include ("c:/wamp/www/Charts/jpgraph-3.5.0b1/src/jpgraph.php");
include ("c:/wamp/www/Charts/jpgraph-3.5.0b1/src/jpgraph_bar.php");
include ("c:/wamp/www/Charts/jpgraph-3.5.0b1/src/jpgraph_line.php");
include ("c:/wamp/www/Charts/jpgraph-3.5.0b1/src/jpgraph_pie.php");
include ("c:/wamp/www/Charts/jpgraph-3.5.0b1/src/jpgraph_pie3d.php");
include ("c:/wamp/www/Charts/jpgraph-3.5.0b1/db.inc");
$host = "localhost";
$username = "root";
$password = "";
$database = "test";
$connection=mysql_connect ($host, $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active mySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
// Select all the rows in the markers table
$sqlTotal = "SELECT count(*) AS Number FROM students";
$total = mysql_query($sqlTotal);
while($resultTotal = mysql_fetch_array($total))
{
$totalValue = $resultTotal['Number'];
}
$data = array($totalValue);
$graph = new PieGraph(410, 310,"auto");
$graph->SetShadow();
$graph->title->Set("Wireless Encryption Schemes in Dublin, Ireland");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$p1 = new PiePlot3D($data);
$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('None','WEP','WPA');
$p1->SetLegends($legends);
$a = array_search(max($data),$data); //Find the position of maixum value.
$p1->ExplodeSlice($a);
$graph->Add($p1);
$graph->Stroke();
?>