<?php

require "conn.php";
$test=0;


$UserLat = $_POST["UserLat"];
$UserLongt = $_POST["UserLongt"];








$res = mysqli_query($con,"SELECT *, (6372.797 * acos(cos(radians($UserLat)) * cos(radians(BrachLat)) * cos(radians(BrachLongt) - radians($UserLongt)) + sin(radians($UserLat)) * sin(radians(BrachLat)))) AS distance FROM CashPlus  ORDER BY distance ASC LIMIT 20");



//$res = mysqli_query($con,"SELECT * FROM Shops WHERE CategoryID ='$CategoryID'");
//$res = mysqli_query($con,"SELECT *, (6372.797 * acos(cos(radians($UserLat)) * cos(radians(ShopLat)) * cos(radians(ShopLongt) - radians($UserLongt)) + sin(radians($UserLongt)) * sin(radians(ShopLat)))) AS distance FROM Shops WHERE CategoryID ='$CategoryID' HAVING distance <= 50 || distance=NULL ORDER BY CategoryID DESC");

$result = array();

$i = 0 ;

$test = 0;

while($row = mysqli_fetch_assoc($res)){

//$data = $row[0];
$result[] = $row;

$test = 4;

}
if($test==4){
    $message ="sucssesfully";
    $success = true;
    $status_code = 200;

echo json_encode(array('status_code' => $status_code,'success' => $success ,"data"=>$result,"message"=>$message));
}
else{
    
    
    
    
    
    
    $message ="sucssesfully";
    $success = true;
    $status_code = 200;

echo json_encode(array('status_code' => $status_code,'success' => $success ,"data"=>$result,"message"=>$message));
}











die;
mysqli_close($con);
?>