<?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 `probeID`, `address`, `name`, `plugged` FROM `probes`");
$result = $mysqli->query($query);
    
while($row = $result->fetch_array(MYSQLI_ASSOC)){
    $data[] = $row;
}

$results = ["sEcho" => 1,
                "iTotalRecords" => count($data),
                "iTotalDisplayRecords" => count($data),
                "aaData" => $data ];
//now print the data
echo json_encode($results); 

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

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

