forked from thomric2/nestgraph
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
43 lines (40 loc) · 1.06 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
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<title>NestGraph</title>
<link rel='stylesheet' type='text/css' href='nest.css'>
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<?php
require 'inc/config.php';
require 'inc/class.db.php';
define('DEFAULT_ID', 1);
$id = DEFAULT_ID;
if (!empty($_GET["id"])) {
$id = $_GET["id"];
}
try {
$db = new DB($config);
if ($stmt = $db->res->prepare("SELECT id,name from devices")) {
$stmt->execute();
$stmt->bind_result($device_id,$device_name);
$options="";
while ($stmt->fetch()) {
$selected = ($id == $device_id)?"selected":"";
$options .= " <option value='$device_id' $selected>$device_name</option>";
}
$stmt->close();
}
$db->close();
} catch (Exception $e) {
$errors[] = ("DB connection error! <code>" . $e->getMessage() . "</code>.");
}
?>
<select id="device_id">
<?php echo $options;?>
</select>
<input name="hours" type="text" id="hours"/> hours
<script src="main.js" charset="utf-8"></script>
</body>
</html>