First of all apologies for any idiocies I may come out with as I am a noobie to fusion charts and sql. I'm just trying to chart data in an sql database with one table that has two fields Date and Result. The result is either approved or not approved. I'm trying to chart how many have been approved in each month...@ present I'm just trying to chart how many have been approved without grouping by date. I've been working on the piechart example, I've tried editing to accomodate my needs but all that is displaying is 'Chart' and no chart.
Regards,
Gary
<?php
//We've included ../Includes/FusionCharts.php and ../Includes/DBConn.php, which contains
//functions to help us easily embed the charts and connect to a database.
include("../Includes/FusionCharts.php");
include("../Includes/DBConn.php");
?>
<HTML>
<HEAD>
<TITLE>
FusionCharts Free - Database Example
</TITLE>
<?php
//You need to include the following JS file, if you intend to embed the chart using JavaScript.
//Embedding using JavaScripts avoids the "Click to Activate..." issue in Internet Explorer
//When you make your own charts, make sure that the path to this JS file is correct. Else, you would get JavaScript errors.
?>
<script LANGUAGE="Javascript" SRC="../../FusionCharts/FusionCharts.js"></SCRIPT>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.text{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</HEAD>
<BODY>
<CENTER>
<h2><a href="http://www.fusioncharts.com" target="_blank">FusionCharts Free</a> -Database and Drill-Down Example</h2>
<?php
//In this example, we show how to connect FusionCharts to a database.
//For the sake of ease, we've used an MySQL databases containing two
//tables.
// Connect to the DB
$link = connectToDB();
//$strXML will be used to store the entire XML document generated
//Generate the graph element
$strXML = "<graph hovercapbg='DEDEBE'
hovercapborder='889E6D'
yAxisMaxValue='100'
numdivlines='9'
divLineColor='CCCCCC'
divLineAlpha='80'
decimalPrecision='0'
showAlternateHGridColor='1'
AlternateHGridAlpha='30'
AlternateHGridColor='CCCCCC'
caption = 'Monthly Approvals'>";
// Fetch all factory records
$strQuery = "select * from testing";
$result = mysql_query($strQuery) or die(mysql_error());
//Iterate through each factory
if ($result) {
while($ors = mysql_fetch_array($result)) {
//Now create a second query to get details for this factory
$strQuery = "select COUNT(Result) AS Approved FROM testing WHERE Result = 'Approved'";
//$strQuery = "select sum(Quantity) as TotOutput from factory_output where FactoryId=" . $ors['FactoryId'];
$result2 = mysql_query($strQuery) or die(mysql_error());
$ors2 = mysql_fetch_array($result2);
//Generate <set name='..' value='..' />
$strXML .= "<set name='" . $ors['Result'] . "' value='" . $ors2['Approved'] . "' />";
//free the resultset
mysql_free_result($result2);
}
}
mysql_close($link);
//Finally, close <graph> element
$strXML .= "</graph>";
//Create the chart - Pie 3D Chart with data from $strXML
echo renderChart("../../FusionCharts/FCF_Column3D.swf", "", $strXML, "Fusion", 650, 450);
?>
<BR><BR>
<a href='../NoChart.html' target="_blank">Unable to see the chart above?</a>
<H5 ><a href='../default.htm'>« Back to list of examples</a></h5>
</CENTER>
</BODY>
</HTML>











