cheesewizz
New member
Good day to all,
I'm new, I don't know much yet, I want to add a symbol to the temperature and humidity such as °C and %H result in my created interface and in the database
below is my doing php with html code.
I really appreciated thank you very much.

I'm new, I don't know much yet, I want to add a symbol to the temperature and humidity such as °C and %H result in my created interface and in the database
below is my doing php with html code.
I really appreciated thank you very much.

<?php
$host = "localhost";
$username = "temp01";
$password = "welcome";
$database = "serverDB_temp";
$con = new mysqli($host, $username, $password, $database);
if($con->connect_error){
echo $con->connect_error;
}
$sql = "SELECT * FROM sensor_data";
$tempserver = $con->query($sql) or die ($con->error);
$row = $tempserver->fetch_assoc();
// do{
// echo $row['name']." ".$row['date_time']. "<br/>";
// }while($row = $tempserver->fetch_assoc());
// ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Temperature and Humidity</title>
<style>
body{
font-family: "Arial";
}
h1{
text-align: center;
}
table{
border: 1px solid black;
border-collapse: collapse;
width: 100%;
}
th, td{
text-align: left;
padding: 8px;
border-bottom: 1px solid black;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h1>Temp and Hum</h1>
<br/>
<br/>
<table>
<thead>
<tr>
<!-- <th>I.D</th> -->
<th>Date and Time</th>
<th>Name</th>
<th>Temperature</th>
<th>Humidity</th>
</tr>
</thead>
<tbody>
<?php do{ ?>
<tr>
<!-- <td><?php echo $row['id']; ?></td> -->
<td><?php echo $row['date_time']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['temperature']; ?></td>
<td><?php echo $row['humidity']; ?></td>
</tr>
<?php }while($row = $tempserver->fetch_assoc()) ?>
</tbody>
</table>
</body>
</html>