arun4444 Posted June 16, 2007 Share Posted June 16, 2007 I have to render a Xml document like this : <chart numdivlines="9" lineThickness="2" showValues="0" anchorRadius="3" anchorBgAlpha="50" showAlternateVGridColor="1" numVisiblePlot="12" animation="1" numberSuffix=" GP"> <categories> <category label="00:00"/> <category label="01:00"/> <category label="02:00"/> <category label="03:00"/> <category label="04:00"/> <category label="05:00"/> <category label="06:00"/> <category label="07:00"/> <category label="08:00"/> <category label="09:00"/> <category label="10:00"/> <category label="11:00"/> <category label="12:00"/> <category label="13:00"/> <category label="14:00"/> <category label="15:00"/> <category label="16:00"/> <category label="17:00"/> <category label="18:00"/> <category label="19:00"/> <category label="20:00"/> <category label="21:00"/> <category label="22:00"/> <category label="23:00"/> </categories> <dataset color="800080" anchorBorderColor="800080"> <set value="54"/> <set value="165"/> <set value="175"/> <set value="190"/> <set value="212"/> <set value="241"/> <set value="308"/> <set value="401"/> <set value="481"/> <set value="851"/> <set value="1250"/> <set value="2415"/> <set value="2886"/> <set value="3252"/> <set value="3673"/> <set value="4026"/> <set value="4470"/> <set value="4813"/> <set value="4961"/> <set value="5086"/> <set value="5284"/> <set value="5391"/> <set value="5657"/> <set value="5847"/> </dataset> </chart> Heres my PHP Code: $strXML = "<chart numdivlines='9' lineThickness='2' showValues='0' anchorRadius='3' anchorBgAlpha='50' showAlternateVGridColor='1' numVisiblePlot='6' animation='1' numberSuffix=' GP'><categories >"; $strQuery = "SELECT * FROM item_price_correction where item_id=1 ORDER BY date ASC LIMIT 0, 9999 "; $result = mysql_query($strQuery) or die(mysql_error()); if ($result) { while($ors = mysql_fetch_array($result)) { $strXML .= "<category label='" . $ors['date'] . "' />"; } } $strXML .= "</categories><dataset color='800080' anchorBorderColor='800080'>"; $strQuery1 = "SELECT * FROM item_price_correction where item_id=1 ORDER BY date ASC LIMIT 0, 9999 "; $result1 = mysql_query($strQuery1) or die(mysql_error()); if ($result1) { while($ors1 = mysql_fetch_array($result1)) { $strXML .= "<set value='" . $ors1['mprice'] . "' />"; } } $strXML .= "</dataset></chart>"; Is there a better way to do this where data is only accessed once, Please keep in mind that i know 5 hours worth of php ty arun Link to comment https://forums.phpfreaks.com/topic/55857-php-xml-help/ Share on other sites More sharing options...
Rojay Posted June 16, 2007 Share Posted June 16, 2007 what do you mean the data is only accessed once? like one SQL query? Link to comment https://forums.phpfreaks.com/topic/55857-php-xml-help/#findComment-275945 Share on other sites More sharing options...
arun4444 Posted June 16, 2007 Author Share Posted June 16, 2007 Yes, Since its accessing data twice, i am afraid that the data might change Link to comment https://forums.phpfreaks.com/topic/55857-php-xml-help/#findComment-275989 Share on other sites More sharing options...
Rojay Posted June 16, 2007 Share Posted June 16, 2007 use this http://www.php.net/function.mysql-data-seek Link to comment https://forums.phpfreaks.com/topic/55857-php-xml-help/#findComment-276035 Share on other sites More sharing options...
arun4444 Posted June 17, 2007 Author Share Posted June 17, 2007 i don't seem to understand. Could you please clarify Link to comment https://forums.phpfreaks.com/topic/55857-php-xml-help/#findComment-276094 Share on other sites More sharing options...
arun4444 Posted June 17, 2007 Author Share Posted June 17, 2007 anyone? Help much appreciated Link to comment https://forums.phpfreaks.com/topic/55857-php-xml-help/#findComment-276295 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.