Código PHP:
<?php
include ("conecta.php");
$file=fopen("1.kml","a") or die("Problemas");
fputs($file,"<?xml version='1.0' encoding='UTF-8'?><kml xmlns='http://www.opengis.net/kml/2.2'>\n");
fputs($file,"<Document>\n");
$query = "SELECT * FROM datosgpx";
mysql_select_db ("datosgpx");
$result = mysql_query($query);
if ($result)
{
while($row = mysql_fetch_array($result))
{
$fecha = $row["fecha"];
$lat = $row["lat"];
$lon = $row["lon"];
$ele = $row["ele"];
$name = $row["name"];
$cmt = $row["cmt"];
[COLOR="Red"]if($cmt!= ""){
$cmt = echo "<img src= 'cf.png'>";
}
else{
$cmt = echo "<img src= 'sf.png'>";
}[/COLOR]
fputs($file,"<Placemark><name>$name</name> <description>$fecha</description> <Style id='randomColorIcon'><IconStyle><scale>1.1</scale><Icon><href>http://maps.google.com/mapfiles/kml/paddle/ylw-blank.png</href></Icon></IconStyle></Style><Point><coordinates>$lat, $lon,$ele</coordinates></Point></Placemark>");
}
}
else
{
echo mysql_error();
}
fputs($file,"</Document></kml>");
fclose($file);
mysql_close();
?>[COLOR="Red"][/COLOR]