-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadDatabase.php
More file actions
47 lines (40 loc) · 837 Bytes
/
readDatabase.php
File metadata and controls
47 lines (40 loc) · 837 Bytes
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
<?php
$servername = "localhost";
$username = "root";
$password = "emidio";
$dbname = "alarmSystem";
$off = "0";
$uid = $_GET['uid'];
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = "SELECT off FROM data";
$result = mysqli_query($conn,$query);
if(!$result){
echo "2";
}else{
while ($row = mysqli_fetch_row($result)) {
if($row[0]=='1'){
$off = "1";
break;
}
}
echo $off;
$off = "0";
}
$query = "SELECT off FROM data WHERE uid = '{$uid}'";
$result = mysqli_query($conn,$query);
if(!$result){
echo "2";
}else{
$row = mysqli_fetch_row($result);
if($row[0]=='1'){
echo "1";
}else{
echo "0";
}
}
?>