-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump2.php
More file actions
55 lines (39 loc) · 1.13 KB
/
dump2.php
File metadata and controls
55 lines (39 loc) · 1.13 KB
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
<?php
/**
* Created by PhpStorm.
* User: incals
* Date: 6/8/2017
* Time: 2:17 AM
*/
require("phpsqlajax_dbinfo.php");
$conn = new mysqli($servername, $username, $password, $database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM markers WHERE 1";
$res = mysqli_query($conn,$sql);
if($res === FALSE) {
die('Not connected : ' . mysqli_error()); // TODO: better error handling
}
else {
$xml = new XMLWriter();
$xml->openURI("php://output");
$xml->startDocument();
$xml->setIndent(true);
$xml->startElement('markers');
while ($row = mysqli_fetch_assoc($res)) {
$xml->startElement("marker");
$xml->writeAttribute('id', $row['id']);
$xml->writeAttribute("name", $row['name']);
$xml->writeAttribute("address", $row['address']);
$xml->writeAttribute("lat", $row['lat']);
$xml->writeAttribute("lng", $row['lng']);
$xml->writeAttribute("type", $row['type']);
$xml->endElement();
}
$xml->endElement();
header('Content-type: text/xml');
$xml->flush();
}
?>