Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to calculate distance from Latitude and longitude

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 297
    Comment on it

    Hello readers!, If you are having a project in PHP and need to calculate the distance from lat and longs you can use the code below:-

    Here all the entries are saved in table('business')

    (SELECT name, ACOS(SIN(RADIANS($latitude))*SIN(RADIANS(business.latitude))+COS(RADIANS($latitude))*
                COS(RADIANS(business.latitude))*COS(RADIANS(business.longitude)-RADIANS($longitude))) * 3959 AS distance,'business'
                 FROM `business` having distance <=5000 ORDER BY distance ASC)";
    

    This Mysql query will give you all the records of which the distance is less than 5000 KM from business table

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: