Este es el codigo que estoy usando:
Código PHP:
Ver originalfunction getTopCustomersXML($intYear, $howMany, $forDataURL) {
// Function to connect to the DB
$link = connectToDB();
$strSQL = "SELECT top " .$howMany. " c.CompanyName as CustomerName, SUM(d.Quantity*p.UnitPrice) As Total, SUM(d.Quantity) As Quantity FROM Customers as c, [Order Details] as d, Orders as o, Products as p WHERE YEAR(OrderDate)=" . $intYear . " and c.CustomerID=o.CustomerID and o.OrderID=d.OrderID and d.ProductID=p.ProductID GROUP BY c.CompanyName ORDER BY Total DESC";
//if ($howMany!=-1)
//$strSQL .= " LIMIT " . $howMany;//no funca en SQL
//Initialize <categories> element
$strCat = "<categories>";
//Initialize datasets
$strAmtDS = "<dataset seriesname='Amount'>";
$strQtyDS = "<dataset seriesName='Quantity' parentYAxis='S'>";
//Iterate through each data row
if ($result) {
$strCat .= "<category label='" . escapeXML($ors['CustomerName'],$forDataURL) . "'/>";
$strAmtDS .= "<set value='" . $ors['Total'] . "'/>";
$strQtyDS .= "<set value='" . $ors['Quantity'] . "'/>";
}
}
//Closing elements
$strCat .= "</categories>";
$strAmtDS .= "</dataset>";
$strQtyDS .= "</dataset>";
//Entire XML - concatenation
$strXML = $strCat . $strAmtDS . $strQtyDS;
return $strXML;
}