Re: writing XML file from MySQL data - foreach loop?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/11/5 David Hine <David.Hine@xxxxxxxxxxxxxxxxxxx>:
> Dear All
> I wish to use java charts to display some time series data that is stored in
> a MySQL database. The time series is the evapotranspiration (average value
> for each day) at a large banana plantation. This will help guide irrigation.
>
> The java charts use an XML file for the data and the formatting.
>
> I have limited the records to 29 days:
> $query = "SELECT DATE_FORMAT(dt, '%d-%m-%Y') AS Day, AVG(ET) as ET FROM
> database.tablename WHERE DATE(dt) BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY)
> AND DATE(NOW()) GROUP BY DATE(dt)";
>
> I use a new DomDocument to format the output.
>
> Once I have the structure of the standard part of the document (calling the
> chart and giving some parameters to it) I want to have a series of strings
> like
>        <number>1.7</number>
>         <number>1.8</number>
>         <number>2.1</number>
>        etc for 29 times....
>
> For that purpose I wrote:
>
> $row = $doc->createElement( "row" );
>  $chart_data->appendChild( $row );
>
>  $number = $doc->createElement( "number" );
> while ($row_etdata = mysql_fetch_array($etdata)){
>    $row->appendChild( $number );
> $txtnode = $doc->createTextNode("$ET");
> $number->appendChild($txtnode);
>
> When I run this or a variant, I get for example <number 1.71.71.71.71.7 for
> 29 times /> Half right is still wrong. Have considered serialize but that
> has its own complexities.
>
> Your assistance or guidance on solving this would be much appreciated.
> thanks
> David Hine
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Take a look at http://dev.mysql.com/tech-resources/articles/xml-in-mysql5.1-6.0.html#xml-5.1-exporting



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux