alesnap1 Report post Posted February 27, 2011 (edited) Hi everyone, I'm newbie with fusioncharts and I'm trying to understand how it works by modifing infosot global. I have this problem...when I try to add a sale (for example on July) with no previous sales, fusioncharts put the sale on the first month which is free from previous sale for this specific product sale. Here's my code: function getCumulativeSalesByCatXML($intYear, $forDataURL) { // Function to connect to the DB $link = connectToDB(); //To store categories - also flag to check whether category is //already generated $catXMLDone = false; //Initialize XML elements $strCat = "<categories>"; //First we need to get unique categories in the database $strSQL = "Select id_categoria,categoria from categoria group by id_categoria,categoria"; $result = mysql_query($strSQL) or die(mysql_error()); //To store datasets and sets $strDataXML = ""; if ($result) { while($orsCat = mysql_fetch_array($result)) { //Add this category as dataset $strDataXML .= "<dataset seriesName='" . escapeXML($orsCat['categoria'],$forDataURL) . "'>"; //Now, we need to get monthly sales data for products in this category $strSQL = "SELECT Month(o.data_movimento) as MonthNum, g.id_categoria, g.categoria, ROUND(SUM(o.carichi),0) as Quantity, SUM(o.scarichi) As Total FROM categoria as g, articoli as p, movimenti_magazzino as o, utenti as d WHERE year(o.data_movimento)=" . $intYear ." and g.id_categoria=" . $orsCat['id_categoria'] . " and o.nome_articolo=p.nome_articolo and o.id_categoria=g.id_categoria and o.utente= d.utente GROUP BY g.id_categoria,g.categoria,Month(o.data_movimento)"; $result2 = mysql_query($strSQL) or die(mysql_error()); while($ors = mysql_fetch_array($result2)) { //Append <category label=''> if not already done if (!$catXMLDone) { $strCat .= "<category label='" . MonthName($ors['MonthNum'],true) . "' />"; } //Generate the link $strLink = urlencode("javaScript:updateProductChart(" . $intYear . "," . $ors['MonthNum'] . "," . $ors['categoria'] . ");"); //Append data $strDataXML .= "<set value='" . $ors['Total'] . "' link='" . $strLink . "'/>"; } //Update flag that we've appended categories $catXMLDone = true; //Clear up objects mysql_free_result($result2); //Close dataset element $strDataXML .= "</dataset>"; } } mysql_close($link); //Close </categories> $strCat .= "</categories>"; //Create full XML $strXML = $strCat . $strDataXML; //Return return $strXML; } And in attach the image where, I hope, someone can understand what I mean. Tnaks for help. Edited February 27, 2011 by alesnap1 Share this post Link to post Share on other sites
alesnap1 Report post Posted February 28, 2011 (edited) Hi, as I haven't seen any answer I tried to rebuild the entire mysql database but I had the same error. I built the entire database as the infosoft database but charts load only the first IDcategory in the "detailed per month sales chart"...and I have also the same error in the "per year and category chart"... In my opinion something goes wrong with the load of the unique category but i'm in stuck..... Any ideas??? Please! Thanks P.S. If I try to make a query as in the code everything goes good! Edited February 28, 2011 by alesnap1 Share this post Link to post Share on other sites