-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_data.php
67 lines (63 loc) · 2.22 KB
/
view_data.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>View Entered Data</title>
<style>
/* Your CSS styles */
</style>
</head>
<body>
<div class="container">
<h2>Entered Data</h2>
<table border="1">
<thead>
<tr>
<th>Gauge ID</th>
<th>Station Name</th>
<th>Gauge Entered By</th>
<th>Gauge Collected By</th>
<th>Gauge Date</th>
<th>Gauge Time</th>
<th>Water Level</th>
</tr>
</thead>
<tbody>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "try";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Fetch data from database
$sql = "SELECT * FROM water_gauge";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// Output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>".$row["gauge_id"]."</td>";
echo "<td>".$row["station_name"]."</td>";
echo "<td>".$row["gauge_entered_by"]."</td>";
echo "<td>".$row["gauge_collected_by"]."</td>";
echo "<td>".$row["gauge_date"]."</td>";
echo "<td>".$row["gauge_time"]."</td>";
echo "<td>".$row["water_level"]."</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='7'>No data found</td></tr>";
}
$conn->close();
?>
</tbody>
</table>
</div>
</body>
</html>