0

I have a table that has two fields (latitude and longitude). I also have a script that gets the users current latitude and longitude.

I want to get all the rows from the table that are <= 50Km from the users location. Calculating the distance is not a problem. My question is how do I restrict unwanted rows in my search result using mysql?

$currentLatitude = 10.999;
$currentLongitude = 23.354;

MYSQL

$this->db->select('latitude, longitude');
$this->db->from('table');
//This is where I have a problem
$this->db->where('distance <=',  50km);

$result = $this->db->get()
dkum
  • 105
  • 8
  • 4
    Provide the sample data and your query. – Siva Apr 12 '18 at 15:10
  • 1
    Possible duplicate of [Find distance between two points using latitude and longitude in mysql](https://stackoverflow.com/questions/24370975/find-distance-between-two-points-using-latitude-and-longitude-in-mysql) – Nico Haase Apr 12 '18 at 15:20
  • @NicoHaase Thanks. Wasn't it exactly but I've been able to modify it to what I need and it's working. Thanks again. – dkum Apr 12 '18 at 15:48

0 Answers0