Showing
1 changed file
with
53 additions
and
0 deletions
import.php
0 → 100644
1 | +<?php | ||
2 | +require("import.php"); | ||
3 | + | ||
4 | +function parseToXML($htmlStr) | ||
5 | +{ | ||
6 | +$xmlStr=str_replace('<','<',$htmlStr); | ||
7 | +$xmlStr=str_replace('>','>',$xmlStr); | ||
8 | +$xmlStr=str_replace('"','"',$xmlStr); | ||
9 | +$xmlStr=str_replace("'",''',$xmlStr); | ||
10 | +$xmlStr=str_replace("&",'&',$xmlStr); | ||
11 | +return $xmlStr; | ||
12 | +} | ||
13 | + | ||
14 | +// Opens a connection to a MySQL server | ||
15 | +$connection=mysql_connect ('localhost', $username, $password); | ||
16 | +if (!$connection) { | ||
17 | + die('Not connected : ' . mysql_error()); | ||
18 | +} | ||
19 | + | ||
20 | +// Set the active MySQL database | ||
21 | +$db_selected = mysql_select_db($database, $connection); | ||
22 | +if (!$db_selected) { | ||
23 | + die ('Can\'t use db : ' . mysql_error()); | ||
24 | +} | ||
25 | + | ||
26 | +// Select all the rows in the markers table | ||
27 | +$query = "SELECT * FROM seoul WHERE 1"; | ||
28 | +$result = mysql_query($query); | ||
29 | +if (!$result) { | ||
30 | + die('Invalid query: ' . mysql_error()); | ||
31 | +} | ||
32 | + | ||
33 | +header("Content-type: seoul/xml"); | ||
34 | + | ||
35 | +// Start XML file, echo parent node | ||
36 | +echo '<markers>'; | ||
37 | + | ||
38 | +// Iterate through the rows, printing XML nodes for each | ||
39 | +while ($row = @mysql_fetch_assoc($result)){ | ||
40 | + // Add to XML document node | ||
41 | + echo '<marker '; | ||
42 | + echo 'name="' . parseToXML($row['name']) . '" '; | ||
43 | + echo 'address="' . parseToXML($row['address']) . '" '; | ||
44 | + echo 'lat="' . $row['lat'] . '" '; | ||
45 | + echo 'lng="' . $row['lng'] . '" '; | ||
46 | + echo 'type="' . $row['type'] . '" '; | ||
47 | + echo '/>'; | ||
48 | +} | ||
49 | + | ||
50 | +// End XML file | ||
51 | +echo '</markers>'; | ||
52 | + | ||
53 | +?> |
-
Please register or login to post a comment