﻿<?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   / can you solve this problem? / 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>Mon, 08 Sep 2008 05:55:15 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: can you solve this problem?</title><link>http://www.fusioncharts.com/forum/Topic5979-43-1.aspx</link><description>Hi,&lt;/P&gt;&lt;P&gt;Could you please try this code as things can be done in various flavours...&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; $arrCat =array();&lt;BR&gt; $strSQL = "SELECT  distinct Month(o.OrderDate) as MonthNum from FC_Orders as o WHERE year(o.OrderDate)=$intYear order by Month(o.OrderDate)";&lt;BR&gt;    $resultCat = mysql_query($strSQL) or die(mysql_error());&lt;BR&gt;    if ($resultCat) {&lt;BR&gt;        while($orsCat = mysql_fetch_array($resultCat)) {&lt;BR&gt;            //Add this category as dataset&lt;BR&gt;   $strCat .= "&amp;lt;category label='" . date("F",mktime(0,0,0,$orsCat['MonthNum'],2,1994)) . "' /&amp;gt;";&lt;BR&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;   mysql_data_seek($resultCat,0);&lt;BR&gt;   while($orsCat1=mysql_fetch_array($resultCat)){&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 Month(o.OrderDate)=". $orsCat1["MonthNum"] ." 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;    $ors = mysql_fetch_array($result2);&lt;BR&gt;    &lt;BR&gt;    if($ors==false){&lt;BR&gt;      $strDataXML .="&amp;lt;set value=''/&amp;gt;";&lt;BR&gt;     &lt;BR&gt;    }else{&lt;BR&gt;     $strLink = urlencode("updateProductChart(" . $intYear . "," . $ors['MonthNum'] . "," . $ors['CategoryID'] . ");");&lt;BR&gt;     $strDataXML .= "&amp;lt;set value='" . $ors['Total'] . "' link='" . $strLink . "'/&amp;gt;";&lt;BR&gt;    }&lt;BR&gt;   &lt;BR&gt;    //Clear up objects&lt;BR&gt;    mysql_free_result($result2);&lt;BR&gt;   }&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>Mon, 28 Apr 2008 09:25:30 GMT</pubDate><dc:creator>Sudipto Choudhury</dc:creator></item><item><title>RE: can you solve this problem?</title><link>http://www.fusioncharts.com/forum/Topic5979-43-1.aspx</link><description>&lt;IMG src="http://www.fusioncharts.com/forum/Uploads/Images/5384f2c0-f3b4-4736-8232-96f4.bmp"&gt;</description><pubDate>Mon, 28 Apr 2008 07:04:48 GMT</pubDate><dc:creator>maheshshinde9</dc:creator></item><item><title>RE: can you solve this problem?</title><link>http://www.fusioncharts.com/forum/Topic5979-43-1.aspx</link><description>But the problem with that code is that it does not show zero (0) for november month.&lt;/P&gt;&lt;P&gt;Means First category (i.e Blue chart) have data only upto august month(i.e 8th month).&lt;/P&gt;&lt;P&gt;So, while loop never get executed for month 11.&lt;/P&gt;&lt;P&gt;Months (label) - Feb,mar,apr,may,june,july,august,november&lt;/P&gt;&lt;P&gt;1st category have data  for months- feb,mar,apr,may,june,july,august&lt;/P&gt;&lt;P&gt;2nd category have data for months - feb,mar,apr,may,june,november&lt;/P&gt;&lt;P&gt;means for 1st category while loop process as follows:&lt;/P&gt;&lt;P&gt;while(2&amp;lt;2) ,while(3&amp;lt;3),while(4&amp;lt;4),while(5&amp;lt;5) ,while(6&amp;lt;6) ,while(7&amp;lt;7),while(8&amp;lt;8) &lt;/P&gt;&lt;P&gt;But after that while loop for month 11 does not execute because 1st category have data&lt;/P&gt;&lt;P&gt;up to 8th month. thats why it does not show zero there .can you tell me solution?</description><pubDate>Mon, 28 Apr 2008 07:03:21 GMT</pubDate><dc:creator>maheshshinde9</dc:creator></item><item><title>can you solve this problem?</title><link>http://www.fusioncharts.com/forum/Topic5979-43-1.aspx</link><description>&lt;IMG height=139 src="http://www.fusioncharts.com/forum/Uploads/Images/03e142b5-a4cb-4524-be7d-5110.bmp" width=453&gt;&lt;/P&gt;&lt;P&gt;I have set the following code to display 0 for particular bar (same code that you have posted to particular thread)&lt;/P&gt;&lt;P&gt;while($arrCat[$mc++]&amp;lt;$ors{'months1'])&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;$strDataXML .="&amp;lt;set value='0.00001'/&amp;gt;";&lt;/P&gt;&lt;P&gt;  }</description><pubDate>Mon, 28 Apr 2008 06:55:09 GMT</pubDate><dc:creator>maheshshinde9</dc:creator></item></channel></rss>