| Server IP : 93.86.61.54 / Your IP : 216.73.216.60 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/projects/rasin_meteo/ |
Upload File : |
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 2px solid white;
border-collapse: collapse;
}
th, td {
padding: 4px;
text-align: center;
}
</style>
<body bgcolor="EEFDEF">
<?php
/*
Rui Santos
Complete project details at https://RandomNerdTutorials.com/esp32-esp8266-mysql-database-php/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
$servername = "localhost";
// REPLACE with your Database name
//$dbname = "REPLACE_WITH_YOUR_DATABASE_NAME";
$dbname = "bme280data";
// REPLACE with Database user
//$username = "REPLACE_WITH_YOUR_USERNAME";
$username = "root";
// REPLACE with Database user password
//$password = "REPLACE_WITH_YOUR_PASSWORD";
$password = "Koren_l0zink@";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, reading_time, sensor, location, value1, value2, value3, value4 FROM SensorData ORDER BY id DESC";
echo "<table style='background-color:#96D4D4'>";
echo "<tr>";
echo "<th>ID</th>";
echo "<th>Vreme</th>";
echo "<th>Sensor</th>";
echo "<th>Location</th> ";
echo "<th>Temperature</th>";
echo "<th>Humidity</th>";
echo "<th>Pressure</th>";
echo "<th>Altitude</th>";
echo "</tr>";
if ($result = $conn->query($sql)) {
while ($row = $result->fetch_assoc()) {
$row_id = $row["id"];
$row_reading_time = $row["reading_time"];
$row_sensor = $row["sensor"];
$row_location = $row["location"];
$row_value1 = $row["value1"];
$row_value2 = $row["value2"];
$row_value3 = $row["value3"];
$row_value4 = $row["value4"];
// Uncomment to set timezone to - 1 hour (you can change 1 to any number)
//$row_reading_time = date("Y-m-d H:i:s", strtotime("$row_reading_time - 1 hours"));
// Uncomment to set timezone to + 4 hours (you can change 4 to any number)
//$row_reading_time = date("Y-m-d H:i:s", strtotime("$row_reading_time + 4 hours"));
echo '<tr>
<td>' . $row_id . '</td>
<td>' . $row_reading_time . '</td>
<td>' . $row_sensor . '</td>
<td>' . $row_location . '</td>
<td>' . $row_value1 . '</td>
<td>' . $row_value2 . '</td>
<td>' . $row_value3 . '</td>
<td>' . $row_value4 . '</td>
</tr>';
}
$result->free();
}
$conn->close();
?>
</table>
</body>
</html>