efonseca Report post Posted January 4, 2009 (edited) hi i'm a newbiee in XML and PHP how can i get more than one set from a DB connection from the example below how can i get a chart with Total and Avaliados.. or more if needed $link = connectToDB(); $useUTFQuery = "SET NAMES 'utf8'"; $utfQueryResult = mysql_query($useUTFQuery); $strQuery = "SELECT Dep, Count(*) AS Total FROM, Count(DataAval) AS Avaliados DAI_main GROUP BY Dep"; $result = mysql_query($strQuery) or die(mysql_error()); $strXML = "graph decimalPrecision='0' rotateNames='0' xaxisname='Departamentos' yaxisname='Colaboradores' showBorder='0' showPercentageValues='0' showPercentageInLabel='0' >"; if ($result) { while($ors = mysql_fetch_array($result)) { $strXML .= "set name='" . $ors['Dep']."' value='" . $ors['Total'] . "' color='FDC12E'/>"; } } mysql_close($link); $strXML .= "/graph>"; echo renderChart("Charts/FCF_Column3D.swf", "", $strXML, "ChartId", 650, 450, false, false); ?> Note: < is taken off so all code can be see Edited January 4, 2009 by Guest Share this post Link to post Share on other sites
efonseca Report post Posted January 4, 2009 (edited) i've triyed like this but i get a invalid xml data. link = connectToDB(); strXML = "graph decimalPrecision='0' rotateNames='0' xaxisname='Departamentos' yaxisname='Colaboradores' showBorder='0' showPercentageValues='0' showPercentageInLabel='0' >"; $strCat = "categories>"; $strTotDS = "dataset seriesname='Total'>"; $strAvalDS = "dataset seriesname='Avaliados'>"; $strQuery = "SELECT Dep, Count(*) AS Total, Count(DataAval) AS Avaliados FROM DAI_main GROUP BY Dep"; $result = mysql_query($strQuery) or die(mysql_error()); if ($result) { while($ors = mysql_fetch_array($result)) { strCat .= "category label='" . $ors['Dep'] . "'/>"; strTotDS .= "set value='" . $ors['Total'] . "' />"; strAvalDS .= "set value='" . $ors['Avaliados'] . "'/>"; } } mysql_close($link); strCat .= "/categories>"; strTotDS .= "/dataset>"; strAvalDS .= "/dataset>"; strXML = $strCat . $strTotDS . $strAvalDS; strXML .= "/graph>"; echo renderChart("/chart/Charts/FCF_Column3D.swf", "", $strXML, "ChartId", 650, 450, false, false); Note: < is taken off so all code can be seen Edited January 4, 2009 by Guest Share this post Link to post Share on other sites
Pallav Report post Posted January 5, 2009 Hi, Can you please run this page and send us the XML output? Share this post Link to post Share on other sites
efonseca Report post Posted January 5, 2009 (edited) chart_ChartId.setDataXML(" categories> category label='AAD'/> category label='CA?'/> category label='CGT'/> category label='CMP'/> category label='CNT'/> category label='COM'/> category label='DAF'/> category label='DCE'/> category label='DGE'/> category label='DID'/> category label='DMN'/> category label='GES'/> category label='INF'/> category label='LAB'/> category label='OPA'/> category label='QLA'/> category label='RH'/> category label='SSG'/> category label='TSR'/> /categories> dataset seriesname='Total'> set value='1' /> set value='2' /> set value='2' /> set value='2' /> set value='4' /> set value='45' /> set value='1' /> set value='3' /> set value='1' /> set value='4' /> set value='29' /> set value='1' /> set value='2' /> set value='9' /> set value='29' /> set value='2' /> set value='3' /> set value='2' /> set value='2' /> /dataset> dataset seriesname='Avaliados'> set value='0'/> set value='0'/> set value='0'/> set value='0'/> set value='0'/> set value='8'/> set value='1'/> set value='0'/> set value='0'/> set value='4'/> set value='0'/> set value='0'/> set value='1'/> set value='0'/> set value='0'/> set value='0'/> set value='0'/> set value='2'/> set value='0'/> /dataset> /graph>") chart_ChartId.render("ChartIdDiv"); Edited January 5, 2009 by Guest Share this post Link to post Share on other sites
Rahul Kumar Report post Posted January 5, 2009 Hi, Could you please save the generated XML into a file & then post that file into this thread? Because we are not able to see the XML correctly. Share this post Link to post Share on other sites
efonseca Report post Posted January 5, 2009 how do i do that? all the code is in a HTML/PHP file. Share this post Link to post Share on other sites
efonseca Report post Posted January 5, 2009 (edited) maybe this can help code.txt Regards EF Edited January 5, 2009 by Guest Share this post Link to post Share on other sites
Rahul Kumar Report post Posted January 5, 2009 (edited) Hi, 1. Your XML should start with <graph> element, that is missing. 2. We have found that your XML contains a ? (Question mark) character, due to this you are getting the error, please remember XML should not contain any special character(s). Also please make sure that, if your Database contains UTF8 character then you are also getting the UTF8 chatacter in your HTML page too, and this UTF character is converted into a ? character, because you might have not saved that HTML/PHP file as UTF8 enabled. So, in order to work with that, please save your HTML/PHP file with UTF8 support. Also please check the code below: link = connectToDB();$strXML = "<graph decimalPrecision='0' rotateNames='0' xaxisname='Departamentos' yaxisname='Colaboradores' showBorder='0' showPercentageValues='0' showPercentageInLabel='0' >"; $strCat = "categories>"; $strTotDS = "dataset seriesname='Total'>"; $strAvalDS = "dataset seriesname='Avaliados'>"; $strQuery = "SELECT Dep, Count(*) AS Total, Count(DataAval) AS Avaliados FROM DAI_main GROUP BY Dep"; $result = mysql_query($strQuery) or die(mysql_error()); if ($result) { while($ors = mysql_fetch_array($result)) { strCat .= "<category label='" . $ors['Dep'] . "'/>"; strTotDS .= "<set value='" . $ors['Total'] . "' />"; strAvalDS .= "<set value='" . $ors['Avaliados'] . "'/>"; } } mysql_close($link); $strCat .= "</categories>"; $strTotDS .= "</dataset>"; $strAvalDS .= "</dataset>"; $strXML .= $strCat . $strTotDS . $strAvalDS; // String concatenation "." was missing. $strXML .= "</graph>"; echo renderChart("/chart/Charts/FCF_Column3D.swf", "", $strXML, "ChartId", 650, 450, false, false); The XML: <graph decimalPrecision='0' rotateNames='0' xaxisname='Departamentos' yaxisname='Colaboradores' showBorder='0' showPercentageValues='0' showPercentageInLabel='0' > <categories> <category label='AAD'/> <category label='CA?'/> <category label='CGT'/> <category label='CMP'/> <category label='CNT'/> <category label='COM'/> <category label='DAF'/> <category label='DCE'/> <category label='DGE'/> <category label='DID'/> <category label='DMN'/> <category label='GES'/> <category label='INF'/> <category label='LAB'/> <category label='OPA'/> <category label='QLA'/> <category label='RH'/> <category label='SSG'/> <category label='TSR'/> </categories> <dataset seriesname='Total'> <set value='1' /> <set value='2' /> <set value='2' /> <set value='2' /> <set value='4' /> <set value='45' /> <set value='1' /> <set value='3' /> <set value='1' /> <set value='4' /> <set value='29' /> <set value='1' /> <set value='2' /> <set value='9' /> <set value='29' /> <set value='2' /> <set value='3' /> <set value='2' /> <set value='2' /> </dataset> <dataset seriesname='Avaliados'> <set value='0'/> <set value='0'/> <set value='0'/> <set value='0'/> <set value='0'/> <set value='8'/> <set value='1'/> <set value='0'/> <set value='0'/> <set value='4'/> <set value='0'/> <set value='0'/> <set value='1'/> <set value='0'/> <set value='0'/> <set value='0'/> <set value='0'/> <set value='2'/> <set value='0'/> </dataset> </graph> Edited January 5, 2009 by Guest Share this post Link to post Share on other sites
efonseca Report post Posted January 6, 2009 (edited) Hi After de correction that you propose i get the "No data to display" the XML looks as before.. Best Regards Eduardo Edited January 6, 2009 by Guest Share this post Link to post Share on other sites
efonseca Report post Posted January 6, 2009 (edited) offcourse it wouldnt work. i was trying to see a multi on a single... i'm so dummmm tks for all your help.. all tested all working going to upgrade.. tks regards Eduardo Edited January 6, 2009 by Guest Share this post Link to post Share on other sites