Hello
I would like to generate a xml file from mysql table using php. I have the following code. it writes xml file in my directory but dont retrive data from my table. below is my code. pls check and help me…
<?php
require_once "dbconnect.php";
$link=dbconnect();
$query=("select *from bband where artist='Meghdol' and album='Shohor Bondi");
$result=mysql_query($query);
$num = mysql_num_rows($result);
if ($num = 0) {
echo "No Records found";
} else {
$file= fopen("results.xml", "w");
$_xml ="<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" ?>\\r\
";
$_xml .="<site>\\r\
";
while ($row = mysql_fetch_array($result)) {
if ($row["link"]) {
$_xml .="\ <page title=\\"" . $row["link"] . "\\">\\r\
";
$_xml .="\ \ <file>" . $row["title"] . "</file>\\r\
";
$_xml .="\ </page>\\r\
";
} else {
$_xml .="\ <page title=\\"Nothing Returned\\">\\r\
";
$_xml .="\ \ <file>none</file>\\r\
";
$_xml .="\ </page>\\r\
";
} }
$_xml .="</site>";
fwrite($file, $_xml);
fclose($file);
echo "XML has been written. <a href=\\"results.xml\\">View the XML.</a>";
} ?>