-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·82 lines (68 loc) · 1.94 KB
/
index.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
// Start MySQL Connection
include('connect.php');
?>
<html>
<head>
<title>Raspberry Pi Sensor Log</title>
<style type="text/css">
.table_titles, .table_cells_odd, .table_cells_even {
padding-right: 20px;
padding-left: 20px;
color: #000;
}
.table_titles {
color: #FFF;
background-color: #000;
}
.table_cells_odd {
background-color: #D7CCC8;
}
.table_cells_even {
background-color: #FAFAFA;
}
table {
border: 2px solid #333;
}
body { font-family: "Trebuchet MS", Arial; }
</style>
</head>
<body>
<h1>Raspberry Pi Sensor Log</h1>
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="table_titles">ID</td>
<td class="table_titles">Date</td>
<td class="table_titles">Temperature</td>
<td class="table_titles">Humidity</td>
<td class="table_titles">Methane Concentration</td>
</tr>
<?php
// Retrieve all records and display them
$result = mysql_query("SELECT * FROM data ORDER BY id DESC");
// Used for row color toggle
$oddrow = true;
// process every record
while( $row = mysql_fetch_array($result) )
{
if ($oddrow)
{
$css_class=' class="table_cells_odd"';
}
else
{
$css_class=' class="table_cells_even"';
}
$oddrow = !$oddrow;
echo '<tr>';
echo ' <td'.$css_class.'>'.$row["id"].'</td>';
echo ' <td'.$css_class.'>'.$row["date"].'</td>';
echo ' <td'.$css_class.'>'.$row["temperature"].'</td>';
echo ' <td'.$css_class.'>'.$row["humidity"].'</td>';
echo ' <td'.$css_class.'>'.$row["ppm"].'</td>';
echo '</tr>';
}
?>
</table>
</body>
</html>