From 47fbac7f1670a995014b2686ecde5cd2203dfd67 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Mon, 15 Aug 2016 00:54:09 +0200 Subject: [PATCH] Add location.php to get last known location --- location.php | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/location.php b/location.php index e69de29..d4f0966 100644 --- a/location.php +++ b/location.php @@ -0,0 +1,53 @@ +connect_error) { + die("Connection failed: " . $conn->connect_error); +} + +$sql = "SELECT ts, lat, lon FROM tracker WHERE device='" . mysqli_real_escape_string($conn, $_GET["device"]) . "' ORDER BY ts DESC LIMIT 1;"; +$result = $conn->query($sql); + +if ($result->num_rows > 0) { + + while($row = $result->fetch_assoc()) { + print ' + + + + Current Location + + + + + + + +

My location at ' . $row["ts"] . '

+

(last known position where I had a GPS signal, a network connection, and some battery power)

+ +
+ + + +'; + } +} else { + die("No records found."); +} + +$conn->close(); + +?> +