-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
33 lines (32 loc) · 1004 Bytes
/
index.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
28
29
30
31
32
33
<?php
$servername = "localhost";
$username = "temperature log user";
$password = "temperature log password";
$dbname = "Temperature";
$data=array();
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname, 0, '/path/to/your/database/mysql/socket');
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT TimeStamp, Temperature FROM Readings where date(TimeStamp)= date(addtime(now(),'11:0:0')) and Source='Deck' order by TimeStamp desc";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo '<a href="month.php">Month</a><table border=1><tr><th>Time</th><th>Temperature</th></tr>';
while($row = $result->fetch_assoc()) {
echo "<tr align=center><td>";
echo $row['TimeStamp'];
echo "</td><td>";
echo $row['Temperature'];
echo "</td></tr>";
}
echo "</table>
</body>
</html>";
} else {
echo "0 results";
}
$conn->close();
?>