Jump to content

Using PHP Code in Smarty


Recommended Posts

I wonder if anyone can help.

 

I have added the below code into a .tpl file for graphing. When I comment out the two include lines everything works fine (obviously not the graphing :) ), and when they are uncommented it seems as though the template files disappear and the are no graphics just wording, and the graphing still does not show up.

 

So I guess the big question is, what stupid thing have I done here?

 

Snippet

 

______________________________________

 

{php}

 

//include("Includes/FusionCharts.php");

//include("Includes/DBConn.php");

 

// Connect to the DB

$link = connectToDB();

 

// [Ryan] changed their code - didnt like it

(isset($_GET["animate"]) && $_GET["animate"] != "") ? $animateChart = $_GET["animate"] : $animateChart = 1;

 

//$strXML will be used to store the entire XML document generated

//Generate the chart element

 

// Fetch all factory records

$strQuery = "select acctsessiontime,Month(acctstoptime) as month, acctinputoctets, acctoutputoctets,AcctInputGigawords,AcctOutputGigawords from radacct where username='steve@aerosat.co.za' group by Month(acctstoptime);";

$result = mysql_query($strQuery) or die(mysql_error());

 

 

//Iterate through each factory

$strXML = "<chart caption='Total Megabytes Transfered' subCaption='Monthly Report' showBorder='0' formatNumberScale='0' numberSuffix=' Megabytes' animation=' " . $animateChart . "' palette='1' showValues='0' yAxisValuesPadding='10'><categories>";

if ($result) {

while($ors = mysql_fetch_array($result)) {

//Now create a second query to get details for this factory

//Note that we're setting link as Detailed.php?FactoryId=<<FactoryId>>

$strXML .= "<category label='".date("M",mktime(0,0,0,$ors["month"],1,2009))."' />";

}

$strXML .="</categories>";

$strXML .= "<dataset seriesName='Upload Megabytes'>";

$result = mysql_query($strQuery) or die(mysql_error());

while($ors = mysql_fetch_array($result)) {

$strXML .= "<set value='".round(($ors["acctinputoctets"]+($ors["AcctInputGigawords"]*4096))/1024/1024,2)."' />";

}

$strXML .= "</dataset>";

$strXML .= "<dataset seriesName='Download Megabytes'>";

$result = mysql_query($strQuery) or die(mysql_error());

while($ors = mysql_fetch_array($result)) {

$strXML .= "<set value='".round(($ors["acctoutputoctets"]+($ors["AcctOutputGigawords"]*4096))/1024/1024,2)."' />";

}

$strXML .= "</dataset>";

$strXML .= "<dataset seriesName='Total Megabytes'>";

$result = mysql_query($strQuery) or die(mysql_error());

while($ors = mysql_fetch_array($result)) {

$strXML .= "<set value='".round((($ors["acctinputoctets"]+($ors["AcctInputGigawords"]*4096)) + ($ors["acctoutputoctets"]+($ors["AcctOutputGigawords"]*4096)))/1024/1024,2)."' />";

}

$strXML .= "</dataset>";

}

mysql_close($link);

 

 

//Finally, close <chart> element

$strXML .= "</chart>";

 

//Create the chart - Pie 3D Chart with data from strXML

echo renderChart("Charts/MSColumnLine3D.swf", "", $strXML, "FactorySum", 600, 300, false, false);

 

{/php}

 

_____________________________________________________________

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated