hi every one,
I m tring to make on webapplication with PHP and MSSQL2005.This simple website has some report and chart those r dynamically update from my MSSQL db.I m using fusion chart free for charting.
I have used this codes for report.
<?php
include('DBConn.php');
include("FusionCharts_Gen.php");
$link = connectToDB();
$stmt=mssql_init("AreaWiseMonthlyRpt", $link);
$date=$_REQUEST['gourl'];
mssql_bind($stmt, "@date", $date, SQLVARCHAR, FALSE);
$result = mssql_execute($stmt);
echo '<table width="900" border="1" align="center" cellpadding="2" cellspacing="0"><tr bgcolor="#999999">';
echo '<th border="1">'.mssql_field_name($result, 0).'</th>';
echo '<th border="1">'.mssql_field_name($result, 3).'</th>';
echo '<th border="1">'.mssql_field_name($result, 4).'</th>';
echo '<th border="1">'.mssql_field_name($result, 6).'</th>';
echo '<th border="1">'.mssql_field_name($result, 7).'</th>';
echo '<th border="1">'.mssql_field_name($result, 9).'</th>';
echo '<th border="1">'.mssql_field_name($result, 10).'</th>';
echo '<th border="1">'.mssql_field_name($result, 13).'</th>';
echo '<th border="1">'.mssql_field_name($result, 15).'</th>';
echo '<th border="1">'.mssql_field_name($result, 16).'</th>';
// Define $color=1
$color="1";
/* Fetch values */
while($rows=mssql_fetch_row($result)){
if($color==1){
echo '<tr bgcolor="#ECE9D8">';
echo '<td border="0">'.$rows["0"].'</td>';
echo '<td border="0">'.$rows["3"].'</td>';
echo '<td border="0">'.$rows["4"].'</td>';
echo '<td border="0">'.$rows["6"].'</td>';
echo '<td border="0">'.$rows["7"].'</td>';
echo '<td border="0">'.$rows["9"].'</td>';
echo '<td border="0">'.$rows["10"].'</td>';
echo '<td border="0">'.$rows["13"].'</td>';
echo '<td border="0">'.$rows["15"].'</td>';
echo '<td border="0">'.$rows["16"].'</td>';
// Set $color==2, for switching to other color
$color='2';
}
// When $color not equal 1, use this table row color
else {
echo '<tr bgcolor="#FFFFFF">';
echo '<td border="0">'.$rows["0"].'</td>';
echo '<td border="0">'.$rows["3"].'</td>';
echo '<td border="0">'.$rows["4"].'</td>';
echo '<td border="0">'.$rows["6"].'</td>';
echo '<td border="0">'.$rows["7"].'</td>';
echo '<td border="0">'.$rows["9"].'</td>';
echo '<td border="0">'.$rows["10"].'</td>';
echo '<td border="0">'.$rows["13"].'</td>';
echo '<td border="0">'.$rows["15"].'</td>';
echo '<td border="0">'.$rows["16"].'</td>';
$color='1';
}
}
echo '</tr></table>';
?>
and code for chart
<?php
# Create pie 3d chart object using FusionCharts PHP Class
$FC = new FusionCharts("Column2D","650","450");
# Set Relative Path of swf file.
$FC->setSwfPath("FusionCharts/");
//Store chart attributes in a variable for ease of use
$strParam="caption=loan Outstanding;subCaption=BDT;pieSliceDepth=30; showBorder=1;showNames=1;formatNumberScale=0;numberSuffix= Units;decimalPrecision=0";
# Set chart attributes
$FC->setChartParams($strParam);
//Pass the SQL Query result to the FusionCharts PHP Class function
//along with field/column names that are storing chart values and corresponding category names
//to set chart data from database
$strQuery=mssql_init("AreaWiseMonthlyRpt", $link);
$date=$_REQUEST['gourl'];
mssql_bind($strQuery, "@date", $date, SQLVARCHAR, FALSE);
$result = mssql_execute($strQuery);
if ($result) {
$FC->addDataFromDatabase($result, "TotalLoanOutstanding", "AreaName");
}
# Render the chart
$FC->renderChart();
?>
it is working well but problem is there are 2 reports and 5 charts in same page. All the chart and reports r using same store procedure "AreaWiseMonthlyRpt". 8 times execution of same procedure make the application very slow.My question is how can i execute the procedure once and reuse every time for every chart. I m new in php programming and I m still learning php.Plz kindly help me.