-
Notifications
You must be signed in to change notification settings - Fork 1
/
allSalePost.php
42 lines (29 loc) · 965 Bytes
/
allSalePost.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
<?php
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
$tp=$_GET['Type'];
$Type="Order by PostID desc";
if(!empty($_GET['Type'])){
$Type="Order By $tp ".$SortType;
}
$lat=$_GET['Lat'];
$lng=$_GET['Lon'];
//$Radius=$_GET['Radius'];
if(!empty($_GET['Type']) && $tp=="Nearest"){
$query = mysql_query("SELECT *,( 3959 * acos( cos( radians('".$lat."') ) * cos( radians( Lat ) ) * cos( radians( Lon ) - radians('".$lng."') ) + sin( radians('".$lat."') ) * sin( radians( Lat ) ) ) ) AS distance FROM Post WHERE Availability=TRUE AND Type1='Sale' HAVING distance < 2");
}
else{
$query = mysql_query("SELECT * FROM `Post` WHERE Availability=TRUE and Type1='Sale' ".$Type);
}
if($query){
while($r = mysql_fetch_assoc($query)) {
$response[] = $r;
//echo "1 ";
}
print json_encode($response);
}
else echo "Error";
?>