View Single Post
Old 03-26-2009, 10:04 AM   PM User | #8
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
PHP Code:
<?php
header
("Content-type: text/xml"); 


include 
'dat.php';
// Connect to server and select databse.
$linkID mysql_connect("$host""$username""$password")or die("cannot connect");
mysql_select_db($db_name$linkID)or die("cannot select DB");
 
$query "SELECT * FROM $tbl_name";
$resultID mysql_query($query$linkID) or die("Data not found.");

$xml_output "<?xml version=\"1.0\" encoding=\"utf8\"?>\n";
$xml_output .= "<ABOUT>\n";

for(
$x $x mysql_num_rows($resultID) ; $x++){
    
$row mysql_fetch_assoc($resultID);
    
$xml_output .= "\t<ISLAND>\n";
    
$xml_output .= "\t\t<ISLAND_NAME>" $row['ISLAND_NAME'] . "</ISLAND_NAME>\n";
    
$xml_output .= "\t\t<ISLAND_DESCR>" $row['ISLAND_DESCR'] . "</ISLAND_DESCR>\n";
    
$xml_output .= "\t\t<ACTIVITIES>" $row['ACTIVITIES'] . "</ACTIVITIES>\n";
    
$xml_output .= "\t\t<EXCURSIONS>" $row['EXCURSIONS'] . "</EXCURSIONS>\n";
    
$xml_output .= "\t\t<ISLAND_PHOTOS>\n";

for (
$z=0;$z<10;$z++;)
{
  
$xml_line "ISLAND_PHOTO_$z";
  if (
$row["$xml_line"] != "") {
  
$xml_output .= "\t\t\t<$xml_line>" $row["$xml_line"] . "</$xml_line>\n";
  }
}

    
$xml_output .= "\t</ISLAND_PHOTOS>\n";
    
$xml_output .= "\t</ISLAND>\n";
}

$xml_output .= "</ABOUT>";

$filenamepath =  "about.xml";
 
 
$fp fopen($filenamepath,'w');

            
fwrite($fp,$xml_output);
            
fclose($filenamepath);
 
 echo 
$xml_output

?>
Try this or something close to it
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Users who have thanked gnomeontherun for this post:
alobarn (03-27-2009)