-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetailsofAllGeofences.php
43 lines (35 loc) · 1.09 KB
/
detailsofAllGeofences.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
define("servername", "localhost");
define("dbusername", "root");
define("dbpassword", "");
define("dbname", "mydb");
if ($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST['username'])){
echo "Session error";
}
else{
$username=$_POST['username'];
$conn = new mysqli(servername, dbusername, dbpassword, dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
//details of all geofence
$query="SELECT id, title, concat(ageFrom,'-',ageTo) as age, gender, type, startDateTime, endDateTime FROM circle WHERE username='$username'
UNION
SELECT id, title, concat(ageFrom,'-',ageTo) as age, gender, type, startDateTime, endDateTime FROM polygon WHERE username='$username' ";
$result= $conn->query($query);
$arrayofData=array();
if ($result->num_rows > 0) {
//output data of each row
while ($row = $result->fetch_assoc()) {
array_push($arrayofData, $row);
}
echo json_encode($arrayofData);
} else{
// echo "Could not successfully run query ($result) from DB: " . mysqli_error($conn);
echo json_encode($arrayofData);
}
$conn->close();
}
}
?>