Thanks for the reply. I have heeded your advice, except I used fopen() instead of simplexml.
OK, please bear with me, i'm new to PHP. So this is what I have now got:
Code: Select all
<?php
require('databaseconnection.php');
// Select all the rows in the markers table
$query = "SELECT * FROM chadwickinfo WHERE 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<pages>';
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo "<link>";
echo "<title>" . $row["name"] . "</title>";
echo "<url>" . $row["photo"] . "</url>";
echo "</link>";
}
// End XML file
echo '</pages>';
$xmlfile = "links2.xml";
$file = fopen($xmlfile,"w");
fwrite($file, "<xml>");
fwrite($file, "<link><title>" . $row["name"] . "</title><url>" . $row["photo"] . "</url></link>");
fwrite($file, "</xml>");
fclose($file);
?>
It still generates the XML string when previewed in the browser, however, I cant see any data added to the "links2.xml" file. Is that last bit of code correct?
Thanks,
Rob
ps I'm using Dreamweaver 8.0, is this sufficient? What is the best PHP program to use?