FragglePete Posted November 26, 2011 Posted November 26, 2011 Once again, I bow to the superior knowledge of those on Edugeek! Another PHP, MySQL problem; I'm trying to produce a Dataset to use within FusionCharts for a project I'm working on, from a query on a MySQL database. The query is sound, and gives the results I need based on various session variables, but it's this bit I'm struggling with... $strXML = ""; //Use the SQL Statement created in MM $query2 = $rsSensorDataRange; //call string query $strCategories = ""; //create categories while ($cat = mysql_fetch_array($query2, MYSQL_ASSOC)) { $strCategories .= ""; //display categories } $strCategories .= ""; $strValues = ""; //create values while ($vals = mysql_fetch_array($query2, MYSQL_ASSOC)) { $strValues .= ""; //display values } $strValues .= ""; //Close the Chart XML String $strXML .= $strCategories . $strValues . ""; //Render the Chart echo renderChart("FusionChartsXT/ZoomLine.swf", "", $strXML, "SensorReading", 790, 400, false, true); The thing works to a point, the first part of the dataset gets created (ie. The Categories), but for some reason the second part (ie. the values) doesn't. I get the opening and closing dataset, but it just refuses to output anything. It seems that the fetch_array gets killed off while the first while bit. I've been staring at this for hours trying to work out why it isn't working! Please help! Cheers Pete
FragglePete Posted November 27, 2011 Author Posted November 27, 2011 I think I've sussed it. I'm still learning, but the code looks like this now at it appears to work: $strXML = ""; //Use the SQL Statement created in MM $query2 = $rsSensorDataRange; //call string $strCategories = ""; //create categories $strValues = ""; //create data series for Values while ($cat = mysql_fetch_array($query2, MYSQL_ASSOC)) { $strCategories .= ""; //display categories from 'TimeOfDay' field $strValues .= ""; //display Values from 'Value' field } $strCategories .= ""; $strValues .= ""; //Close the Chart XML String $strXML .= $strCategories . $strValues . ""; //Render the Chart echo renderChart("FusionChartsXT/ZoomLine.swf", "", $strXML, "SensorReading", 790, 400, false, true); ?>
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now