jokecoat
Posts: 43
|
| Posted: 06/14/2011, 2:54 AM |
|
Hi,
I'm using this (http://forums.codecharge.com/posts.php?post_id=91164) code to generate a XML file for FlashChart. But now i want to link it to the outcome of grid1.
The SQL of grid1 is:
SELECT jaar, maand, avg(totaal) AS gem FROM vw_ronde_totaal WHERE speler_id = {Expr0} AND baan_id = {Expr1} GROUP BY jaar, maand ORDER BY datum
and the code for XML output is
$db = new clsDBlocalhost();
$strQuery ="SELECT jaar, maand, Avg(totaal) AS gem FROM vw_ronde_totaal WHERE speler_id = 9 AND baan_id = 1 GROUP BY jaar, maand ORDER BY datum ASC" ;
$db->query($strQuery);
$rows=$db->num_rows($db->f("jaar")); //get number of rows returned by the query
$Array1=array();
$Array2=array();
$i=0;
while($db->next_record())
{
$Array1[$i] = $db->f("maand");
$Array2[$i] = $db->f("gem");
$i++;
}
$strXML ="<chart><chart_data><row><null/>"; // xml generation
for($i=0;$i<$rows;$i++) $strXML.="<string>".$Array1[$i]."</string>";
$strXML.="</row><row><string></string>";
for($i=0;$i<$rows;$i++) $strXML.="<number>".$Array2[$i]."</number>";
// The xml string has been constructed.. We now dump this string into a XML file
$myfile="example.xml";
$myfilehandle= fopen($myfile, 'w') or die("can't open file");
fclose($myfilehandle);
$fh = fopen($myfile, 'w') or die("can't open file");
fwrite($fh, $strXML);
fclose($fh);
$db->close();
How can i get the grid1 output in the code for the XML output?
|