-
Notifications
You must be signed in to change notification settings - Fork 0
/
pauseActiveGeofenceTypePolygon.php
49 lines (38 loc) · 1.11 KB
/
pauseActiveGeofenceTypePolygon.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
<?php
define("servername", "localhost");
define("dbusername", "root");
define("dbpassword", "");
define("dbname", "mydb");
if ($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST['id'])){
echo "Session error";
}
else{
$id=$_POST['id'];
$conn = new mysqli(servername, dbusername, dbpassword, dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
//details of all geofence
$query="SELECT id, datediff(endDateTime, startDateTime) as days, status FROM polygon WHERE id='$id' AND status='Active' Having days > 0";
$result= $conn->query($query);
if ($result->num_rows > 0) {
$updatequery= "UPDATE polygon SET status='Paused' WHERE id='$id'";
if ($conn->query($updatequery) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
} else{
$updatequery2= "UPDATE polygon SET status='Active' WHERE id='$id'";
if ($conn->query($updatequery2) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
exit;
}
$conn->close();
}
}
?>