Hello I need to get PHP to order the output of the XML file
to be
ACENDING to the numerical value of the XML
<start_day></start_day>
tags
PHP Script...
<?php
function makexmltree($getmonth) {
$doc = new DOMDocument();
$doc->load( 'newxml.xml' );
//gets info from xml
$icount == 1;
echo "<br><table width='100%' border='0'
cellpadding='5'
cellspacing='0' class='table_searchresult2'>";
$books = $doc->getElementsByTagName( "event"
);
foreach( $books as $book )
{
$product_nos = $book->getElementsByTagName(
"product_no" );
$product_no = $product_nos->item(0)->nodeValue;
$product_codes = $book->getElementsByTagName(
"product_code" );
$product_code =
$product_codes->item(0)->nodeValue;
$product_names = $book->getElementsByTagName(
"product_name" );
$product_name = $product_names->item(0)->nodeValue;
$event_venues = $book->getElementsByTagName(
"event_venue" );
$event_venue = $event_venues->item(0)->nodeValue;
$bookpaths = $book-
>getElementsByTagName(
"running_period_of_event" );
foreach( $bookpaths as $bookpath )
{
$start_days= $bookpath->getElementsByTagName(
"start_day" );
$start_day= $start_days->item(0)->nodeValue;
$start_months= $bookpath->getElementsByTagName(
"start_month" );
$start_month= $start_months->item(0)->nodeValue;
$start_years= $bookpath->getElementsByTagName(
"start_year" );
$start_year= $start_years->item(0)->nodeValue;
$end_days= $bookpath->getElementsByTagName(
"end_day" );
$end_day= $end_days->item(0)->nodeValue;
$end_months= $bookpath->getElementsByTagName(
"end_month" );
$end_month= $end_months->item(0)->nodeValue;
$end_years= $bookpath->getElementsByTagName(
"end_year" );
$end_year= $end_years->item(0)->nodeValue;
}
//start build... for each
if ($start_month == $getmonth) {
echo "<tr>";
if (($icount) == 1) {
$tablecolour = "<td bgcolor='#CCCCCC'>";
$icount = "0";
} else {
$tablecolour = "<td bgcolor='#FFFFFF'>";
$icount = 1;
}
echo $tablecolour
."<a href='http://www.visitbirmingham.com/exec/103657/31676/pno
=".
$product_no
.",pcode=".$product_code
."'
target='_blank'>".$product_name."</a><
br>"
."<strong>".$event_venue." &
lt;/strong></td>"
.$tablecolour
.$start_day." "
.$start_month." - "
.$end_day." "
.$end_month." "
.$end_year."</td></tr>"/n;
}
$start_day = "";
$start_month = "";
$start_year ="";
$end_day = "";
$end_month ="";
$end_year="";
$event_venue="";
$product_name="";
$product_code="";
$product_no="";
}
echo "</table>";
makexmltree("July");
?>
XML File (trimed down)
<dataroot>
<event><product_no>10790</product_no>
<product_code>GBMBL6295E</product_code>
<product_name>Gwen Stefani</product_name>
<running_period_of_event>
<start_day>25</start_day>
<start_month>September</start_month>
<start_year>2007</start_year>
<end_day>25</end_day>
<end_month>September</end_month>
<end_year>2007</end_year>
</running_period_of_event>
<event_venue>The nia academy</event_venue>
</event>
<event>
<product_no>3027</product_no>
<product_code>GBMBL0329E</product_code>
<product_name>Berlioz Restaurant</product_name>
<running_period_of_event>
<start_day>10</start_day>
<start_month>May</start_month>
<start_year>2006</start_year>
<end_day>10</end_day>
<end_month>May</end_month>
<end_year>2010</end_year>
</running_period_of_event>
<event_venue></event_venue>
</event>
</dataroot>
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---
|