FusionCharts Support

Dynamic chart creation - reading tables to chart from MySQL

Recommended Posts





In one Mysql table I have a column that lists the names of all of my target tables that I would like to draw a chart for. I start off with reading the column of tables, then do another SELECT statement to open each of these tables individually and draw a Line chart for each one.




The result that I am getting is one chart that shows correct data for one table only. In fact for the last table in the list. For all other tables I only get the word "Chart." displayed.




I am stuck. I think, it is most likely that I have the wrong order of statements in my two fetch_array loops but I cannot seem to figure it out. Hoping someone here can review my PHP code and help me identify the problem.




Here is my code:



$qry1="SELECT allTables FROM MyTables";

 $res1=mysql_query($qry1) or die(mysql_error());

	while ($row = mysql_fetch_array($res1))  {

		$table = $row['allTables'];

		$strXML = "";

				$qry2  ="SELECT * FROM $table";

				$res2 = mysql_query($qry2) or die(mysql_error());

						while ($row2= mysql_fetch_array($res2))  {

							$status = $row2['status'];

							$Date = $row2['Date'];

						$strXML .= "";


					$strXML .= "";

 		echo renderChart("Line.swf", "", $strXML, "Status Data", 500, 350, false, false);

echo "";








Thank you,








P.S. The $strXML variable is not showing up properly in the post. I have them populated with the right info, chart caption and set label & value. They are present when I'm editing the post but in the preview and final post you only see an empty $strXML variable assignment. I am not sure why, this is my first post ever in this Forum.

Edited by Guest

Share this post

Link to post
Share on other sites





There can be many reasons behind showing "Chart.".




1. FusionCharts.js is not loaded or incorrect path set for this file in your application. Please make sure that you are loading FusionCharts.js properly.




2. due to JavaScript error. You might be passing value with NEW LINE character in which which will break down the code.




Could you please send (attach) us the HTML that is getting generated?

Share this post

Link to post
Share on other sites

Thanks for the reply. I figured it out, it was as I suspected just the order of logic statements; the FusionCharts elements and files were all there and accessible. I dug deep into my code and finally figured it out. works like a charm now.





Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now