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 = 0 ; $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