diff --git a/day.php b/day.php new file mode 100644 index 0000000..bb4494e --- /dev/null +++ b/day.php @@ -0,0 +1,57 @@ +connect_error) { + die("Connection failed: " . $conn->connect_error); +} + +$sql = "SELECT ts, lat, lon FROM tracker WHERE device='" . mysqli_real_escape_string($conn, $_GET["device"]) . "' AND DATE(ts)='".date("Y-m-d")."' ORDER BY ts ASC;"; +$result = $conn->query($sql); + +if ($result->num_rows > 0) { + header('Content-Type: application/vnd.google-earth.kml+xml'); + header('Content-Disposition: attachment; filename="export.kml"'); + echo ' + + + + + #style + 1a1ac94e + #ffff00 + 0.4980392156862745 + 4 + #00ff00 + 0.4980392156862745 + + + +'; + + while($row = $result->fetch_assoc()) { + echo $row["lon"] . "," . $row["lat"] . "\n"; + } + + echo ' + +'; + +} else { + die("No records found."); +} + +$conn->close(); + +?> +