Generate KML/KMZ/XML with PHP query

Keepaitulteme

New Member
I'am trying to generate a KML using php, but i got an error screen, on line 1, here is my document:\[code\]<?phpheader('Content-type: text/xml');include('../../../../../../config.php');// Print the head of the documentecho htmlentities('<?xml version="1.0" encoding="UTF-8"?>');echo '</br>';echo htmlentities('<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">');echo '</br>';echo htmlentities('<Document>');echo '</br>'; // Finally query the database data$result = mysql_query("SELECT * FROM acars_airports ORDER BY id DESC"); // Now iterate over all placemarks (rows)while ($row = mysql_fetch_array($result)) { // This writes out a placemark with some data // -- Modify for your case --echo htmlentities('<Placemark>');echo '</br>';echo htmlentities('<name>'.$row['icao'].'</name>');echo '</br>';echo htmlentities('<description>'.$row['name'].'</description>');echo '</br>';echo htmlentities('<Point>');echo '</br>';echo htmlentities('<coordinates>'.$row['lon'].' , '.$row['lat'].'</coordinates>');echo '</br>';echo htmlentities('</Point>');echo '</br>';echo htmlentities('</Placemark>');echo '</br>'; };// And finish the documentecho htmlentities('</Document>');echo '</br>';echo htmlentities('</kml>');?>\[/code\]Forget about the query! How can i generate a KML/KMZ/XML file to be read on a google maps map?Already tried:\[code\]header('Content-type: text/xml');header('Content-type: application/vnd.google-earth.kmz');\[/code\]
 
Back
Top