Here I want to calculate the distance between locations, after calculating the subsequent data will be displayed only has the smallest distance. but i am confused how to make based on data such as the following:
and here my wp_postmeta :
and here my code :
<?php
$latitude = "23.139422";
$longitude = "-82.382617";
mysql_query( 'SELECT ( 3959 * acos( cos( radians( '.$latitude.' ) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians( '.$longitude.' ) ) + sin( radians( '.$latitude.' ))
* sin( radians( latitude ) ) ) )
AS distance from wp_posts
HAVING distance <= 100
ORDER BY distance ASC'
)
i dont know how to i take the latitude and longitude by id the post_id
have someone tell me what i need imporve in my code so its can be work like what i want ? Thanks kyu
-