<?php  // this is used for the data tables on system settings
    //setting header to json
    header('Content-Type: application/json');
    header("Access-Control-Allow-Origin: *");

    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 * FROM `ds18b20`");
    $query = sprintf("SELECT `address`, `name`, `plugged`, `graphVisible`, `graphRange`, `graphAverage`, `min`, `max` FROM `probes`");

    //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 the data
    print json_encode($dataWindow); 



// //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);