-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFetch.php
More file actions
30 lines (27 loc) · 956 Bytes
/
Fetch.php
File metadata and controls
30 lines (27 loc) · 956 Bytes
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
<?php
$servername = "den1.mysql5.gear.host";
$username = "plantdata1";
$password = "XXX"; // need to change to real PW
$dbname = "plantdata1";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM plantdata1.plaeddit_data ORDER BY dateofcare DESC LIMIT 1;";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<h2>Most Recent Results: </h2><br>"
. "<p id='temperature'>Temperature: " . $row["temperature"] . "</p><br>"
. "<p id='humidity'>Humidity: " . $row["humidity"] . "</p><br>"
. "<p id='moisture'>Moisture: " . $row["moisture"] . "</p><br>"
. "<p id='time'>Time: " . $row["dateofcare"] . "</p><br>";
}
} else {
echo "0 results";
}
$conn->close();
?>