Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = "root";
- $password = "";
- $database = "map";
- $connection = mysql_connect('localhost', $username, $password);
- if(!$connection) {
- while(!$connection){
- $connection = mysql_connect('localhost', $username, $password);
- }
- }
- $db_selected = mysql_select_db($database, $connection);
- if(!$db_selected){
- while(!$db_selected){
- $db_selected = mysql_select_db($database, $connection);
- }
- }
- $query = "SELECT markers.lng, markers.lat, locations.name AS location_name,
- locations.address, locations.type, locations.phone, locations.email,
- locations.`work-hours`, locations.description, cities.name AS city_name,
- countries.name AS country_name, countries.continent
- FROM markers JOIN locations
- ON markers.location_id = locations.id
- JOIN cities ON locations.city_id = cities.id
- JOIN countries ON cities.country_id = countries.id";
- $result = mysql_query($query);
- if(!$result){
- while(!$result){
- $result = mysql_query($query);
- }
- }
- $dom = new DOMDocument("1.0");
- $node = $dom->createElement("markers");
- $parnode = $dom->appendChild($node);
- header("Content-type: text/xml");
- while ($row = @mysql_fetch_assoc($result)){
- $node = $dom->createElement("marker");
- $newnode = $parnode->appendChild($node);
- $newnode->setAttribute("lat", $row['lat']);
- $newnode->setAttribute("lng", $row['lng']);
- $newnode->setAttribute("location_name", $row['location_name']);
- $newnode->setAttribute("address", $row['address']);
- $newnode->setAttribute("type", $row['type']);
- $newnode->setAttribute("phone", $row['phone']);
- $newnode->setAttribute("email", $row['email']);
- $newnode->setAttribute("work-hours", $row['work-hours']);
- $newnode->setAttribute("description", $row['description']);
- $newnode->setAttribute("city_name", $row['city_name']);
- $newnode->setAttribute("country_name", $row['country_name']);
- $newnode->setAttribute("continent", $row['continent']);
- }
- echo $dom->saveXML();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement