Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

php get closest location by latitude longitude

SELECT * , (3956 * 2 * ASIN(SQRT( POWER(SIN(( $lat - LatOnTable) *  pi()/180 / 2), 2) +COS( $lat * pi()/180) * COS(LatOnTable * pi()/180) * POWER(SIN(( $long - LongOnTable) * pi()/180 / 2), 2) ))) as distance  
from yourTable  
having  distance <= 10 
order by distance
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #closest #location #latitude #longitude
ADD COMMENT
Topic
Name
5+9 =