forked from bislara/room_automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
56 lines (42 loc) · 953 Bytes
/
update.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
54
55
56
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script>
$(document).ready(function() {
$('button').click(function(){
$("$_GET['id']").toggle();
});
});
</script>
<?php
include 'db.php';
if ($_GET['id']) {
// echo $_GET['id'];
$id=$_GET['id'];
$query1 = "SELECT * FROM appliances WHERE id = '$id'";
$res = mysqli_query($con, $query1);
$status=0;
$query='';
if($res)
{
$row = mysqli_fetch_array($res, MYSQLI_ASSOC);
$status = $row['status'];
}
if($status==0)
{
$query = mysqli_query($con,"UPDATE appliances SET status='1' WHERE id=$id ");
}
else if($status==1)
{
$query = mysqli_query($con,"UPDATE appliances SET status='0' WHERE id=$id ");
}
if($query)
{
echo "Update sucessful";
}
else
{
echo "helani";
}
header('Location: abcd.php');
}
?>