<?php
    //setting header to json
    header('Content-Type: application/json');
    header("Access-Control-Allow-Origin: *");
    header('Clear-Site-Data: "*"');
    // header('chrome://settings/siteData');

    require '../php/database.php';

    //query to get data from the table
    // $query = sprintf("SELECT timestamp, temp1, temp2, temp3, temp4, temp5 FROM data");
    $query = sprintf("SELECT `userID`, `version`, `versionLatest` FROM `systemSettings` WHERE `userID` = 1");

    //execute query
    $result = $mysqli->query($query);

    //loop through the returned data
    $dataWindow = array();
    foreach ($result as $row) {
        $dataWindow[] = $row;
    }

    //free memory associated with result
    $result->close();

    //close connection
    $mysqli->close();
    // print_r(json_encode($dataWindow));
    //now print the data
    print json_encode($dataWindow);