|
|
|
Forum Member
      
Group: Forum Members
Last Login: 4/29/2008 4:06:17 AM
Posts: 44,
Visits: 93
|
|
| 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: $MonthArray=array(); while($oRs=mysql_fetch_array($result)){ $MonthArray[$oRs['Month']]=$oRs['TotalSales']; } // we again retireve the monthly revenue value form array and create set XML elements for each month for($i=1;$i<=12;$i++){ $strXML .= "<set value='" . $MonthArray[$i] . "' />"; } Instead of $strXML I have used $strCat . Means you have used for loop out of while loop. In our categorywise sales example, you have used mysql_data_seek() function. I made 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) & I think this is because of we are using mysql_data_seek($resultCat) . Could'nt you make changes to the your code? (even though As my need is a bit different from the original design you had)
|
|
|
|
|
Supreme Being
      
Group: Moderators
Last Login: Today @ 6:02:32 AM
Posts: 764,
Visits: 1,215
|
|
| Hi, Could you please check if this code helps : //getCumulativeSalesByCatXML returns the cumulative sales for each category //in a given year function getCumulativeSalesByCatXML($intYear, $forDataURL) { // Function to connect to the DB $link = connectToDB(); //To store categories - also flag to check whether category is //already generated //Initialize XML elements //Categories $strCat = "<categories>"; for($mn =1;$mn<=12;$mn++){ //Add this category as dataset $strCat .= "<category label='" . date("F",mktime(0,0,0,$mn,2,1994)) . "' />"; } $strCat .= "</categories>"; //First we need to get unique categories in the database $strSQL = "Select CategoryID,CategoryName from FC_Categories GROUP BY CategoryID,CategoryName"; $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['CategoryName'],$forDataURL) . "'>"; //Now, we need to get monthly sales data for products in this category $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)"; //Execute it $result2 = mysql_query($strSQL) or die(mysql_error()); $MonthArray=array(); while($ors=mysql_fetch_array($result2)){ $MonthArray[$ors["MonthNum"]]=$ors['Total']; } for($i=1;$i<=12;$i++){ if($MonthArray[$i]){ $strLink = urlencode("updateProductChart(" . $intYear . "," . $i . "," .$orsCat['CategoryID'] . ");"); $strDataXML .= "<set value='" . $MonthArray[$i] . "' link='" . $strLink . "'/>"; }else{ $strDataXML .="<set value=''/>"; } } //Clear up objects mysql_free_result($result2); //Close dataset element $strDataXML .= "</dataset>"; } } mysql_close($link); //Create full XML $strXML = $strCat . $strDataXML; //Return return $strXML; }
Regards,
Sudipto Choudhury FusionCharts Team
|
|
|
|