Hi, apologies if this is really stupid and simple but have been tearing hair out for last few hours.
Am a newbie to php and fusioncharts
Seem to behaving a problem displaying graph from php retrieved from Mysql. Php code below retrieves data from mysql and plots via fusioncharts and html.
Except not really working.
Receiving a variable from another php file that sets the table for mysql table.
If manually put $x = "table", code works fine and graph is displayed but not when using a passed in variable!!
Passed in variable is ok though and echos correct data if needed.
Apologies again if seems too simple but not to me!!
any help would be appreciated
?php
//include("getuser.php");
$con = mysql_connect('localhost', 'root', 'admin');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
echo $x;
$result = mysql_query("SELECT * FROM $x");
/
$xmlData = "<graph caption='Inactivity Status' xAxisName='Time' yAxisName='Watts' decimalPrecision='0' formatNumberScale='0'>";
while($row = mysql_fetch_array($result))
{
$chart =$row['Electricity Usage'];
$time =$row['Time'];
$xmlData .= "<set name='" . $row['Time'] . "' value='" . $row['Electricity Usage']. "' color='000000' />";
}
$xmlData .= "</graph>";
mysql_close($con);
echo $xmlData;
?>