<?php
include ("connect.php");
// Get parameters from URL
//$fsearch = $_GET["fsearch"];
$asearch = $_GET["asearch"];
//$asearch = 'phuket';
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
// Opens a connection to a mySQL server
$connection=mysql_connect ($dbhostname, $dbusername, $dbpassword);
mysql_query("SET NAMES UTF8",$connection);
if (!$connection) {
die("Not connected : " . mysql_error());
}
// Set the active mySQL database
$db_selected = mysql_select_db($dbname, $connection);
if (!$db_selected) {
die ("Can\'t use db : " . mysql_error());
}
//$query = "select message.*, Detail.*, MessageType.* from message, Detail, MessageType where message.detailID = Detail.detailID and message.memberTypeID = MessageType.memberTypeID and message.name like '%$asearch%' or message.THname like '%$asearch%' or message.location like '%$asearch%' or MessageType.memberType like '%$asearch%'";
$query = "select message.*, Detail.*, MessageType.* from ( Detail inner join message on Detail.detailID=message.detailID ) inner join MessageType on message.memberTypeID=MessageType.memberTypeID where message.name like '%$asearch%' or message.THname like '%$asearch%' or message.location like '%$asearch%' or MessageType.memberType like '%$asearch%' or MessageType.THmemberType like '%$asearch%'";
$result = mysql_query($query);
if (!$result) {
die("Invalid query: " . mysql_error());
}
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("detailID", $row['detailID']);
$newnode->setAttribute("detail", $row['detail']);
$newnode->setAttribute("THdetail", $row['THdetail']);
$newnode->setAttribute("memberTypeID", $row['memberTypeID']);
$newnode->setAttribute("memberType", $row['memberType']);
$newnode->setAttribute("THmemberType", $row['THmemberType']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lon", $row['lon']);
$newnode->setAttribute("location", $row['location']);
$newnode->setAttribute("name", $row['name']);
$newnode->setAttribute("THname", $row['THname']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("THaddress", $row['THaddress']);
$newnode->setAttribute("tel", $row['tel']);
$newnode->setAttribute("web", $row['web']);
$newnode->setAttribute("email", $row['email']);
$newnode->setAttribute("status", $row['status']);
$newnode->setAttribute("photo1", $row['photo1']);
$newnode->setAttribute("photo2", $row['photo2']);
$newnode->setAttribute("photo3", $row['photo3']);
$newnode->setAttribute("photo4", $row['photo4']);
$newnode->setAttribute("photo5", $row['photo5']);
$newnode->setAttribute("photo6", $row['photo6']);
}
echo $dom->saveXML();
?>