Jump to content

Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.