-
Notifications
You must be signed in to change notification settings - Fork 0
/
gettotalbytypes.php
executable file
·43 lines (36 loc) · 1012 Bytes
/
gettotalbytypes.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
<?php
require_once('config.php');
require_once('loginneeded.php');
$roomid=$_GET['roomid'];
if (empty($roomid)) {
$sql = "SELECT * FROM devices";
} else {
$sql = "SELECT * FROM devices WHERE roomid='$roomid'";
}
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$typeid=$row['device_type_id'];
$stats[$typeid]['total']++;
}
}
foreach ($stats as $key => $stat) {
$sql = "SELECT * FROM device_types WHERE device_type_id='$key'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$typename=$row['device_type_name'];
$total=$stat['total'];
$charti['value']=$total;
$charti['color']="Blue";
$charti['highlight']="Blue";
$charti['label']=$typename;
$charts[]=$charti;
// echo "<p>$key";
// print_r($faultstat);
}
//$smarty->assign("faultstats", $faultstats);
//print_r($faultstats);
//print_r($charts);
echo json_encode($charts);
die();