-
Notifications
You must be signed in to change notification settings - Fork 0
/
getTemp.php
27 lines (23 loc) · 853 Bytes
/
getTemp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
require_once "config.php";
//
// //echo "Success!";
$sqlNow = sprintf("SELECT * FROM Data order by Id desc limit 1");
$sqlLow = sprintf("SELECT Temp FROM (SELECT * FROM `Data` order by Id DESC LIMIT 96) As dataa ORDER BY Temp LIMIT 1");
$sqlHigh = sprintf("SELECT Temp FROM (SELECT * FROM `Data` order by Id DESC LIMIT 96) As dataa ORDER BY Temp desc LIMIT 1");
$datasettNow = mysqli_query($conn,$sqlNow);
$datasettLow = mysqli_query($conn,$sqlLow);
$datasettHigh = mysqli_query($conn,$sqlHigh);
while ($row3 = mysqli_fetch_array($datasettNow)){
$now = $row3["Temp"];
$nowTime = $row3["Date"];
$nowId = $row3["Id"];
}
while ($row4 = mysqli_fetch_array($datasettLow)){
$low = $row4["Temp"];
}
while ($row5 = mysqli_fetch_array($datasettHigh)){
$high = $row5["Temp"];
}
echo json_encode(array($now, $low, $high, $nowTime, $nowId));
?>