1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to calculate distance using lattitude and longitude

Discussion in 'PHP' started by JEET, Dec 18, 2015.

  1. #1
    Hello,
    I'll try to explain as best as I can.

    I got LAT and LONG of an address.
    I have another LAT and LONG for a different address, which is within 10 miles from the first one.
    I have a third LAT and LONG for a different address, which is within 20 miles from the first one.
    They are all stored in a mysql table.
    My table looks like this:

    id, LATI, LONGI, ADDRESS

    I need to return the address which is within 10 miles from the first one. What query should I use?
    The query should only return the second address, and not the third one.
    If I have the two, I can use Haversine formula to calculate the distance, but here I got only the first one and I need to find the ones (second, etc) which are within 10 miles.

    Thanks
     
    Solved! View solution.
    JEET, Dec 18, 2015 IP
  2. JEET

    JEET Notable Member

    Messages:
    3,825
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #3
    Thanks :) That was what I was looking for!
     
    JEET, Dec 19, 2015 IP
  3. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #4
    Becareful with those links. There are a lot of bad answers on those forums. You don't want to perform a math operation column by column when retrieving records.
     
    NetStar, Dec 20, 2015 IP