<?php
//setting header to json
header('Content-Type: application/json');
header("Access-Control-Allow-Origin: *");

require 'database.php';

//query to get data from the table
// $query = sprintf("SELECT timestamp, temp1, temp2, temp3, temp4, temp5 FROM data");
$query = sprintf("SELECT `buttonID`, `label` FROM `button_labels`");

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

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