bergenrothn Report post Posted September 25, 2016 I am trying to pass an xml string into the datasource argument and I keep getting an invalid data message when I load the page. Any help would be appreciated. <head> <title>FusionCharts XT - Column 2D Chart - Data from a database</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <!-- Include the `fusioncharts.js` file. This file is needed to render the chart. Ensure that the path to this JS file is correct. Otherwise, it may lead to JavaScript errors. --> <script src="fusioncharts/fusioncharts.js"></script> </head> <?php include("fusioncharts/fusioncharts.php"); $servername = "localhost"; $username = "*****"; $password = "****"; $dbname = "***"; // Create connection $dbhandle = new mysqli($servername, $username, $password, $dbname); // Check connection if ($dbhandle->connect_error) { die("Connection failed: " . $dbhandle->connect_error); } $dbhandle = new mysqli($servername, $username, $password, $dbname); // Render an error message, to avoid abrupt failure, if the database connection parameters are incorrect if ($dbhandle->connect_error) { exit("There was an error with your connection: ".$dbhandle->connect_error); } // Form the SQL query that returns the top 10 most populous countries $strQuery = "SELECT * FROM scores"; //$retval = mysql_query( $sql, $conn ); // Execute the query, or else return the error message. $result = $dbhandle->query($strQuery) or exit("Error code ({$dbhandle->errno}): {$dbhandle->error}"); //while($row = mysql_fetch_assoc($result)) { // echo "Category :{$row['category']} <br> ". // "score : {$row['score']} <br> ". // "--------------------------------<br>"; // } $strXML ="'<chart><categories>"; // If the query returns a valid response, prepare the XML string if ($result) { // The `$arrData` array holds the chart attributes and data //$arrData["data"] = array(); // Push the data into the array while($row = mysqli_fetch_array($result)) { $strQuery2 = "select * from desirescores where ID =" . $row['ID']; //echo $strQuery2; $result2 = mysqli_query($dbhandle, $strQuery2) or die(mysqli_error()); $ors2 = mysqli_fetch_array($result2); //Generate <set label='..' value='..'/> //free the resultset $strXML .= "<category label='" . $ors2['category'] . "' />"; mysqli_free_result($result2); } } $strXML .= "</categories><dataset seriesName='Athlete Scores'>"; $strXML .="<set value='35' /><set value='48' /><set value='31' /><set value='40' /><set value='36' /><set value='36' /><set value='36' /><set value='36' /></dataset></chart>'"; echo $strXML; $radarChart = new FusionCharts("radar", "myFirstChart" , 600, 300, "chart-1", "XML", $strXML); $radarChart->render(); $dbhandle->close(); ?> <div id="chart-1"><!-- Fusion Charts will render here--></div> Share this post Link to post Share on other sites
Prerana Report post Posted September 26, 2016 Hello, Thanks for the query. I have tried to create a sample as per your requirement. Kindly refer the link below for the implementation. https://www.dropbox.com/s/3v42xh6y6n5uqbo/RadarChart_sql_php.zip?dl=0 For further details about creating charts in PHP using Database, please refer the link below. http://www.fusioncharts.com/dev/using-with-server-side-languages/php/creating-charts-with-data-from-a-database.html Hope this helps, Thanks, Share this post Link to post Share on other sites