Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerate KML/KMZ/XML with PHP query
    text
    copied!<p>I'am trying to generate a KML using php, but i got an error screen, on line 1, here is my document:</p> <pre><code>&lt;?php header('Content-type: text/xml'); include('../../../../../../config.php'); // Print the head of the document echo htmlentities('&lt;?xml version="1.0" encoding="UTF-8"?&gt;'); echo '&lt;/br&gt;'; echo htmlentities('&lt;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"&gt;'); echo '&lt;/br&gt;'; echo htmlentities('&lt;Document&gt;'); echo '&lt;/br&gt;'; // 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('&lt;Placemark&gt;'); echo '&lt;/br&gt;'; echo htmlentities('&lt;name&gt;'.$row['icao'].'&lt;/name&gt;'); echo '&lt;/br&gt;'; echo htmlentities('&lt;description&gt;'.$row['name'].'&lt;/description&gt;'); echo '&lt;/br&gt;'; echo htmlentities('&lt;Point&gt;'); echo '&lt;/br&gt;'; echo htmlentities('&lt;coordinates&gt;'.$row['lon'].' , '.$row['lat'].'&lt;/coordinates&gt;'); echo '&lt;/br&gt;'; echo htmlentities('&lt;/Point&gt;'); echo '&lt;/br&gt;'; echo htmlentities('&lt;/Placemark&gt;'); echo '&lt;/br&gt;'; }; // And finish the document echo htmlentities('&lt;/Document&gt;'); echo '&lt;/br&gt;'; echo htmlentities('&lt;/kml&gt;'); ?&gt; </code></pre> <p>Forget about the query! How can i generate a KML/KMZ/XML file to be read on a google maps map?</p> <p>Already tried:</p> <pre><code>header('Content-type: text/xml'); header('Content-type: application/vnd.google-earth.kmz'); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload