-
Notifications
You must be signed in to change notification settings - Fork 0
/
getdevice.php
executable file
·53 lines (49 loc) · 1.86 KB
/
getdevice.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
<?php
require_once('config.php');
require_once('loginneeded.php');
$sql = "SELECT * FROM devices WHERE device_id='$deviceid'";
echo $sql;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$workingcount['working']=0;
$workingcount['faulty']=0;
while($row = $result->fetch_assoc()) {
//device_id,device_type_id,device_makeid,device_hbnumber_device_working
$device['id']=$row['device_id'];
$typeid=$row['device_type_id'];
$device['type_id']=$typeid;
$sql="SELECT * FROM device_types WHERE device_type_id='$typeid'";
$resulttype = mysqli_query($conn,$sql);
$rowtype = mysqli_fetch_row($resulttype);
$device['type']=$rowtype[1];
$makeid=$row['device_makeid'];
$device['makeid']=$makeid;
$sql="SELECT * FROM device_makes WHERE device_make_id='$makeid'";
$resultmake = mysqli_query($conn,$sql);
$rowmake = mysqli_fetch_row($resultmake);
$device['make']=$rowmake[1];
$device['hbnumber']=$row['device_hbnumber'];
$device['comment']=$row['device_comment'];
$working=$row['device_working'];
if ($working) {
$device['working']="Working";
$workingcount['working']++;
} else {
$device['working']="Faulty";
$workingcount['faulty']++;
}
}
} else {
$smarty->assign("error","<p>Invalid device, mayby someone has deleted it?");
$smarty->display('error.tpl');
die();
}
print_r($device);
//die();
$smarty->assign("DEVICE_HBNUMBER", $device['hbnumber']);
$smarty->assign("DEVICE_TYPEID", $typeid);
$smarty->assign("DEVICE_MAKEID", $makeid);
$smarty->assign("WORKING", $working);
$smarty->assign("COMMENT", $device['comment']);
$smarty->assign("workingcount", $workingcount);