-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions.php
36 lines (27 loc) · 1 KB
/
functions.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
<?php include "db.php";
function showData($attribute) {
global $connection;
$query = "SELECT * FROM datapoints GROUP BY " . $attribute;
$result = mysqli_query($connection, $query);
if (!$result) {
die('Query FAILED' . mysqli_error());
}
while($row = mysqli_fetch_assoc($result)) {
$data = $row[$attribute];
echo "<option value=''>$data</option>";
}
}
function showDayOfWeek($dateAttribute) {
global $connection;
$query = "SELECT * FROM datapoints GROUP BY " . $dateAttribute;
$result = mysqli_query($connection, $query);
if (!$result) {
die('Query FAILED' . mysqli_error());
}
while($row = mysqli_fetch_assoc($result)) {
$date = $row[$dateAttribute];
$unixTimestamp = strtotime($date);
$weekday = date("l", $unixTimestamp);
echo "<option value=''>$weekday</option>";
}
}