I've made a php file to access mysql and write to an xml file, i need to port this file to postgres. i'm very new to postgres and would appreciate any help people can provide in making this transition.
<?php
$link = mysql_connect ("localhost", "administrator", "password");
mysql_select_db("IAD", $link);
$_xml = ( bool ) false;
$result = mysql_query ("describe users", $link);
$count = 0;
while ($row = mysql_fetch_array($result)) {
$fieldnames[$count] = $row[0];
$count++;
}
$file= fopen("user.xml" , "w");
$_xml .="<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\r\n";
$_xml .="<!-- table users -->";
$_xml .="<users>\r\n";
$result = mysql_query ("select * from users", $link);
while ($row = mysql_fetch_object($result)) {
$count = 0;
$_xml .=" <record>\r\n";
foreach ($row as $data) {
$_xml .=" <$fieldnames[$count]>$data</$fieldnames[$count]>\r\n";
$count++;
}
$_xml .=" </record>\r\n";
}
$_xml .="</users>";
fwrite($file, $_xml);
fclose($file);
echo $_xml;
mysql_close ($link);
?>
Cheers for taking the time to look through my code.