i'm in the process of porting a mysql script to psql, i've made a number of changes to this script but it still will not generate the xml as i want it to.
Would appreciate any help someone could offer.
<?php
$conn = pg_connect("host=172.16.8.180 user=icm02rm password='' dbname=icm02rm");
if (!$conn)
{
echo "<h1>Connection Error</h1>";
exit;
}
$sql="SELECT * FROM flock;";
$result_set = pg_exec($conn, $sql);
$rows = pg_numrows($result_set);
for ($j=0; $j<$rows; $j++)
{
list($flock_number,$flock_location) = pg_fetch_row($result_set, $j);
}
$file= fopen("flock.xml" , "w");
$_xml .="<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\r\n";
$_xml .="<!-- table users 2-->";
$_xml .="<flock>\r\n";
$result_set = pg_Exec ($conn, $sql);
for ($j=0; $j<$row; $j++) {
$row = pg_fetch_array($result, $row);
$_xml .=" <record>\r\n";
foreach ($row as $data) {
$_xml .=" <$fieldnames[$count]>$data</$fieldnames[$count]>\r\n";
$count++;
}
$_xml .=" </record>\r\n";
}
//}
$_xml .="</flock>";
fwrite($file, $_xml);
fclose($file);
echo $_xml;
pg_close();
?>
This is the xml output:
<?xml version="1.0" encoding="iso-8859-1" ?>
<!-- table users 2 -->
<flock />
Cheers for the help.