﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>FusionCharts Forum / FusionCharts Free / FusionCharts Free and PHP   / couldn't you make changes to you code that you have provided in particualr thread. / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>FusionCharts Forum</description><link>http://www.fusioncharts.com/forum/</link><webMaster>support@fusioncharts.com</webMaster><lastBuildDate>Sun, 07 Sep 2008 05:22:43 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: couldn't you make changes to you code that you have provided in particualr thread.</title><link>http://www.fusioncharts.com/forum/Topic5997-43-1.aspx</link><description>Hi,&lt;/P&gt;&lt;P&gt;Could you please check if this code helps :&lt;/P&gt;&lt;P&gt;//getCumulativeSalesByCatXML returns the cumulative sales for each category&lt;BR&gt;//in a given year&lt;BR&gt;function getCumulativeSalesByCatXML($intYear, $forDataURL) {&lt;/P&gt;&lt;P&gt;    // Function to connect to the DB&lt;BR&gt;    $link = connectToDB();&lt;/P&gt;&lt;P&gt;    //To store categories - also flag to check whether category is&lt;BR&gt; //already generated&lt;BR&gt; &lt;BR&gt; //Initialize XML elements&lt;BR&gt; //Categories&lt;BR&gt; $strCat = "&amp;lt;categories&amp;gt;";&lt;BR&gt; for($mn =1;$mn&amp;lt;=12;$mn++){&lt;BR&gt;  //Add this category as dataset&lt;BR&gt;  $strCat .= "&amp;lt;category label='" . date("F",mktime(0,0,0,$mn,2,1994)) . "' /&amp;gt;";&lt;BR&gt; }&lt;BR&gt; &lt;BR&gt; $strCat .= "&amp;lt;/categories&amp;gt;";&lt;BR&gt;  &lt;BR&gt; &lt;BR&gt; &lt;BR&gt; //First we need to get unique categories in the database&lt;BR&gt; $strSQL = "Select CategoryID,CategoryName from FC_Categories GROUP BY CategoryID,CategoryName";&lt;BR&gt;    $result = mysql_query($strSQL) or die(mysql_error());&lt;BR&gt;  &lt;BR&gt;    //To store datasets and sets&lt;BR&gt;    $strDataXML = "";&lt;/P&gt;&lt;P&gt;    if ($result) {&lt;BR&gt;        while($orsCat = mysql_fetch_array($result)) {&lt;BR&gt;            //Add this category as dataset&lt;BR&gt;            $strDataXML .= "&amp;lt;dataset seriesName='" . escapeXML($orsCat['CategoryName'],$forDataURL) . "'&amp;gt;";&lt;BR&gt;   &lt;BR&gt;    &lt;BR&gt;    //Now, we need to get monthly sales data for products in this category&lt;BR&gt;    $strSQL = "SELECT  Month(o.OrderDate) as MonthNum, g.CategoryID, g.CategoryName, ROUND(SUM(d.Quantity),0) as Quantity, SUM(d.Quantity*p.UnitPrice) As Total FROM FC_Categories as g,  FC_Products as p, FC_Orders as o, FC_OrderDetails as d  WHERE year(o.OrderDate)=" . $intYear ." and g.CategoryID=" . $orsCat['CategoryID'] . " and d.ProductID=p.ProductId and g.CategoryID= p.CategoryID and o.OrderID= d.OrderID GROUP BY g.CategoryID,g.CategoryName,Month(o.OrderDate) order by Month(o.OrderDate)";&lt;BR&gt;    //Execute it&lt;BR&gt;    $result2 = mysql_query($strSQL) or die(mysql_error());&lt;BR&gt;    $MonthArray=array();&lt;BR&gt;    while($ors=mysql_fetch_array($result2)){&lt;BR&gt;     $MonthArray[$ors["MonthNum"]]=$ors['Total'];&lt;BR&gt;    }&lt;BR&gt;    for($i=1;$i&amp;lt;=12;$i++){&lt;BR&gt;     if($MonthArray[$i]){&lt;BR&gt;     $strLink = urlencode("updateProductChart(" . $intYear . "," . $i . "," .$orsCat['CategoryID'] . ");");&lt;BR&gt;     $strDataXML .= "&amp;lt;set value='" . $MonthArray[$i] . "' link='" . $strLink . "'/&amp;gt;";&lt;BR&gt;      &lt;BR&gt;     }else{ &lt;BR&gt;      $strDataXML .="&amp;lt;set value=''/&amp;gt;";&lt;BR&gt;     }&lt;BR&gt;    }&lt;BR&gt;   &lt;BR&gt;    //Clear up objects&lt;BR&gt;    mysql_free_result($result2);&lt;BR&gt;        //Close dataset element&lt;BR&gt;        $strDataXML .= "&amp;lt;/dataset&amp;gt;";&lt;BR&gt;   }&lt;BR&gt;    }&lt;BR&gt;    mysql_close($link);&lt;/P&gt;&lt;P&gt; //Create full XML&lt;BR&gt; $strXML = $strCat . $strDataXML;&lt;/P&gt;&lt;P&gt;    //Return&lt;BR&gt; return $strXML;&lt;BR&gt;}</description><pubDate>Tue, 29 Apr 2008 04:30:37 GMT</pubDate><dc:creator>Sudipto Choudhury</dc:creator></item><item><title>couldn't you make changes to you code that you have provided in particualr thread.</title><link>http://www.fusioncharts.com/forum/Topic5997-43-1.aspx</link><description>Suggestion that you have made( could you please download the FusionWidgets Blueprint Application code and refer to function buildXMLMonthlyRev() in DataGen.php) contains following code:&lt;/P&gt;&lt;P&gt;$MonthArray=array(); &lt;BR&gt; while($oRs=mysql_fetch_array($result)){&lt;BR&gt;     $MonthArray[$oRs['Month']]=$oRs['TotalSales'];&lt;BR&gt;  &lt;BR&gt; }&lt;BR&gt; // we again retireve the monthly revenue value form array and create set XML elements for each month&lt;BR&gt; for($i=1;$i&amp;lt;=12;$i++){&lt;BR&gt;  $strXML .= "&amp;lt;set value='" . $MonthArray[$i] . "' /&amp;gt;";&lt;BR&gt; }&lt;/P&gt;&lt;P&gt;Instead of $strXML I have used $strCat .&lt;/P&gt;&lt;P&gt;Means you have used for loop out of while loop.&lt;/P&gt;&lt;P&gt;In our categorywise sales example, you have used mysql_data_seek() function. I made &lt;/P&gt;&lt;P&gt;changes to the my code as per above code. But because of this for loop( which out of while loop) it does not display proper labels (means month labels) &amp;amp; I think this is because of&lt;/P&gt;&lt;P&gt;we are using mysql_data_seek($resultCat) . Could'nt you make changes to the your code?&lt;/P&gt;&lt;P&gt;(even though As my need is a bit different from the original design you had)</description><pubDate>Tue, 29 Apr 2008 02:58:22 GMT</pubDate><dc:creator>maheshshinde9</dc:creator></item></channel></rss>