Get the keyword from user's input value(city name), and search similar city name in database.
Return filtered information into google map xml format.
createElement("markers");
$parnode = $doc->appendChild($node);
header("Content-type: text/xml");
$sql = 'select * FROM church';
$query = "select * FROM church WHERE ch_city LIKE \"%$trimmed%\" ";
//echo $sql;
$posts = $wpdb->get_results($query); // Run our query, getting results as an object
if (!empty($posts)) { // If the query returned something
foreach ($posts as $post) {
$address = $post->ch_street.'+'.$post->ch_city.'+'.$post->ch_state.'+'.$post->ch_zip;
$node = $doc->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name",$post->ch_name);
$newnode->setAttribute("address",$address);
}
}
echo $doc->saveXML();
?>
No comments:
Post a Comment