nashsaint Posted February 12, 2009 Share Posted February 12, 2009 Hi, I searched the forum for solution to my problem but there seems to be no reply to all queries. I am posting this topic again hoping to get lucky. This is my code: mysql_select_db($database_perDB, $perDB); $query_currentJobs = "SELECT * FROM job_details WHERE status = 'current' ORDER BY date DESC"; $startRow_currentJobs, $maxRows_currentJobs); $currentJobs = mysql_query($query_limit_currentJobs, $perDB) or die(mysql_error()); $row_currentJobs = mysql_fetch_assoc($currentJobs); My intention is to generate xml file from this query for use with fusionchart. Help is greatly appreciated. thanks. Link to comment https://forums.phpfreaks.com/topic/144948-sql-query-to-xml/ Share on other sites More sharing options...
andy_b42 Posted February 12, 2009 Share Posted February 12, 2009 Im not familiar with fusionchart, but if you are wanting to write the contents of the query result to an XML file, you can use the XMLwriter classes, but i prefer for smaller xml files to just output a file formatted as XML as though i were making a text. <?php $xml = "<?xml version = '1.0' encoding = 'UTF-8'?>\n"; $xml .= "<container>\n"; $xml .= "\t<parent name=\"some value\">\n"; $xml .= "\t\t<child variable=\"some value\">\n"; $xml .= "\t\t<child variable=\"some value\">\n"; $xml .= "\t</parent>\n"; $xml .= "\t<parent name=\"some value\">\n"; $xml .= "\t\t<child variable=\"some value\">\n"; $xml .= "\t\t<child variable=\"some value\">\n"; $xml .= "\t</parent>\n"; $xml .= "</container>\n"; $openFileToWrite = fopen("myXML.xml", "w"); fwrite ($openFileToWrite, $xml); fclose ($openFileToWrite); ?> Very quick and very dirty, but it works. If your xml files are going to be quite big or you are using this sort of thing a lot, you should consider looking into the appropriate classes designed for writing xml files as this method can quickly become a pain to deal with. Link to comment https://forums.phpfreaks.com/topic/144948-sql-query-to-xml/#findComment-760700 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.