<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="refresh" content="5" >
    <link rel="stylesheet" type="text/css" href="style.css" media="screen"/>
    <script src="https://cdn.tailwindcss.com"></script>

	<title> Sensor Data </title>

</head>

<body>

    <h1>SENSOR DATA</h1>
<?php
$servername = "localhost";
$user = "root";
$password = "";
$dbname = "datasensor";

// Create connection
$conn = new mysqli($servername, $user,$password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT id, Tank1, Tank2, rainwater, Turbidity,pH_sensor, reading_time FROM sensordata ORDER BY id DESC"; /*select items to display from the sensordata table in the data base*/

echo '<table cellspacing="5" cellpadding="5">
      <tr> 
         
        <th>Storage Tank</th> 
        <th>PotashAlum Tank</thh> 
        
        <th>Turbidity</th> 
        <th>pH_sensor</th>      
        <th>Data Time</th> 
      </tr>';
 
if ($result = $conn->query($sql)) {
    while ($row = $result->fetch_assoc()) {
       
        $row_Tank1 = $row["Tank1"];
        $row_Tank2 = $row["Tank2"]; 
        $row_Turbidity = $row["Turbidity"];
        $row_pH_sensor = $row["pH_sensor"];
        $row_reading_time = $row["reading_time"]; 

        echo '<tr> 
               
                <td>' . $row_Tank1 . '</td> 
                <td>' . $row_Tank2 . '</td> 
                
                <td>' . $row_Turbidity . '</td> 
                <td>' . $row_pH_sensor . '</td>
                <td>' . $row_reading_time . '</td>
                
                
              </tr>';
    }
    $result->free();
}

$conn->close();
?> 
</table>


</div>

</body>
</html>

	</body>
</html>