-
Notifications
You must be signed in to change notification settings - Fork 0
/
traerDenunciasWeb.php
56 lines (47 loc) · 1.39 KB
/
traerDenunciasWeb.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
$servername = "127.0.0.1:51533";
$username = "azure";
$password = "6#vWHD_$";
$dbname = "db";
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 ($servername, $username, $password);
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());
}
// Select all the rows in the markers table
$query = "SELECT latitud, longitud, tipo, descripcion, fecha FROM misdenuncias";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<markers>';
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// Add to XML document node
echo '<marker ';
echo 'latitud="' . $row['latitud'] . '" ';
echo 'longitud="' . $row['longitud'] . '" ';
echo 'tipo="' . $row['tipo'] . '" ';
echo 'descripcion="' . $row['descripcion'] . '" ';
echo 'fecha="' . $row['fecha'] . '" ';
echo '/>';
}
// End XML file
echo '</markers>';
?>