<?php
error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE & ~E_DEPRECATED);
session_start();
ob_start();
if($_SESSION['sml_si']!=session_id()) {
    die();
}
require_once("../functions.php");
require_once("../../db/connection.php");
$id = strip_tags($_POST['id']);
$return = array();
$query = "SELECT lat,lon FROM sml_live_tracking_history WHERE id=? ORDER BY tracked_at ASC;";
if($smt = $mysqli->prepare($query)) {
    $smt->bind_param('s',$id);
    $result = $smt->execute();
    if($result) {
        $result = get_result($smt);
        if(count($result)>0) {
            while($row = array_shift($result)) {
                $return[] = [$row['lon'],$row['lat']];
            }
        }
    }
}
ob_end_clean();
echo json_encode($return);