<?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 `address`, `name`, `plugged`, `graphVisible`, `graphRange`, `graphAverage`, `min`, `max` FROM `ds18b20`");


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

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

//print the data
print json_encode($dataWindow); 

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

//close connection
$mysqli->close();

