-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetData.php
More file actions
49 lines (33 loc) · 1019 Bytes
/
Copy pathgetData.php
File metadata and controls
49 lines (33 loc) · 1019 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
48
49
<?php
$host = "localhost";
$user = "root";
$password = "root";
$dbname = "nasa_v2";
$con = mysqli_connect($host, $user, $password,$dbname);
// Check connection
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
$data = json_decode(file_get_contents("php://input"));
$search = $data->searchText; // Search value
$sortColumn = $data->sortColumn; // Sort Column name
$sortOrder = $data->sortOrder; // Boolean value
$sortBy = "asc";
if($sortOrder){
$sortBy = "desc";
}
$select_emp = "select * from fake_love where 1 ";
if($search != ''){
$select_emp .= " and (date like '%".$search."%')";
}
$select_emp .= " order by ".$sortColumn." ".$sortBy;
$fetchRecords = mysqli_query($con,$select_emp);
$data = array();
while ($row = mysqli_fetch_array($fetchRecords)) {
$data[] = array("date" => $row['date'],
"time" => $row['time'],
"longitude" => $row['latitude'],
"latitude" => $row['longitude']
);
}
echo json_encode($data);