1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- ini_set("display_errors", "1");
- error_reporting(E_ALL);
- require("connection.php");
- // Opens a connection to a MySQL server
- $connection=mysql_connect ($dbhost, $dbuser, $dbpass);
- if (!$connection) {
- die('Not connected : ' . mysql_error());
- }
- // Set the active MySQL database
- $db_selected = mysql_select_db($db, $connection);
- if (!$db_selected) {
- die ('Can\'t use db : ' . mysql_error());
- }
- // Select all the rows in the markers table
- $query = "SELECT * FROM markers WHERE 1 ORDER BY timestamp";
- $result = mysql_query($query);
- if (!$result) {
- die('Invalid query: ' . mysql_error());
- }
- // Iterate through the rows, adding XML nodes for each
- while ($row = @mysql_fetch_assoc($result)){
- $row['lat'] = doubleval($row['lat']);
- $row['lng'] = doubleval($row['lng']);
- $row['alt'] = floatval($row['alt']);
- $row['hdop'] = intval($row['hdop']);
- $row['timestamp'] = strtotime($row['timestamp']);
- $row['format'] = date('d.m.Y H:i:s', $row['timestamp']);
- $json[] = $row;
- }
- echo json_encode($json);
- ?>
|