Skip to main content

Posts

Showing posts with the label MYSQL

Create XML File From Mysql Table

How to create XMLFile Form Mysql Table function createXMLFile($result, $feildLength, $dir) { $headers = array(); $xmlData = array(); $str = ""; $counter = 0; for ($i=0;$i<$feildLength;$i++) { array_push($headers, mysql_field_name($result, $i)); } $xmlFileData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; while ($row = mysql_fetch_array($result)) { for ($i=0;$i<$feildLength;$i++) { $str .= "<".trim($headers[$i]).">" . escapeXMLEntities(trim($row[$i])) . "</".trim($headers[$i]).">\n"; $counter++; //increment column# if ($counter == $feildLength) { //new row array_push($xmlData, "<record>\n" . $str . "</record>\n"); $str = ""; $counter = 0; } } } $xmlFileData .= "<records name=\"Customer_Table\">\n" . implode("", $xmlData) . "</records&g