57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
header("Content-type: text/xml");
|
|
|
|
require("phpsqlajax_dbinfo.php");
|
|
|
|
//don't change unless you change this value in the db.
|
|
$prefix = "gforum_";
|
|
$main_table = "OpenWater";
|
|
$field_lead = "openwater_";
|
|
|
|
function parseToXML($htmlStr)
|
|
{
|
|
$xmlStr=str_replace('<','<',$htmlStr);
|
|
$xmlStr=str_replace('>','>',$xmlStr);
|
|
$xmlStr=str_replace('"','"',$xmlStr);
|
|
$xmlStr=str_replace("'",''',$xmlStr);
|
|
$xmlStr=str_replace("&",'&',$xmlStr);
|
|
return $xmlStr;
|
|
}
|
|
|
|
// Opens a connection to a MySQL server
|
|
$connection=mysql_connect ($host, $username, $password);
|
|
if (!$connection) {
|
|
die('Not connected : ' . mysql_error());
|
|
}
|
|
|
|
// Set the active MySQL database
|
|
$db_selected = mysql_select_db($database, $connection);
|
|
if (!$db_selected) {
|
|
die ('Can\'t use db : ' . mysql_error());
|
|
}
|
|
|
|
// Select all the rows in the markers table
|
|
$query = "SELECT ".$field_lead."name, ".$field_lead."lat, ".$field_lead."lng FROM ".$prefix.$main_table." WHERE ".$field_lead."lat <> 0 AND ".$field_lead."lng <> 0";
|
|
$result = mysql_query($query);
|
|
if (!$result) {
|
|
die('Invalid query: ' . mysql_error());
|
|
}
|
|
|
|
// Start XML file, echo parent node
|
|
echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
|
|
echo '<markers>'.PHP_EOL;
|
|
|
|
// Iterate through the rows, printing XML nodes for each
|
|
while ($row = @mysql_fetch_assoc($result)){
|
|
// ADD TO XML DOCUMENT NODE
|
|
echo '<marker';
|
|
echo ' name="' . parseToXML($row[''.$field_lead.'name']) . '" ';
|
|
echo 'lat="' . $row[''.$field_lead.'lat'] . '" ';
|
|
echo 'lng="' . $row[''.$field_lead.'lng'] . '" ';
|
|
echo '/>'.PHP_EOL;
|
|
}
|
|
|
|
// End XML file
|
|
echo '</markers>';
|
|
|
|
?>
|