Points nearby locations database

Hi ,
what is the MySQL 5.0 query needs to select geo
coordinates( latitude,longitude) from locations database
within a radius of 100 miles around this center :
map.setCenter(new GLatLng(“.$initial_lat.”,“.$initial_lng.”) ;
and display this markers in the Google Maps ?
Please I tried before the distance calculation of My SQL :

  map.setCenter(new GLatLng(".$initial_lat.",".$initial_lng.") ; 

and display this markers in the Google Maps ?
Please I tried before the distance calculation of My SQL :

(3963*acos(cos(radians($initial_lat))*cos(radians(lat))*cos(radians(lng)-
radians($initial_lng))+sin(radians($initial_lat))*sin(radians(lat))))
AS distance FROM agoda_hotel
WHERE agoda_hotel.country_id = 205
HAVING distance < 100

however it’ s not select locations nearby the center above
correctly. I am newbie in MySQL programming and may be I
could not found the exact function.
thanks.

I am not sure if it is really working accurately but what I had done a couple of months before something like this:


if($lat && $lng){
    // 1 km = 0.6213711 miles
    $miles = $srch_within * 0.6213711; // $srch_within is in km so converting to miles
    $lat1 = $lat - ($miles / 69.1);
    $lng1 = $lng - ($miles / 53);
    
    $lat2 = $lat + ($miles / 69.1);
    $lng2 = $lng + ($miles / 53);
    
    $where[] = "(p.posLat>=$lat1 AND p.posLat<=$lat2 AND p.posLng>=$lng1 AND p.posLng<=$lng2)";
}

I did not give much time because this was not in my priority at that moment. Try and see if this works for you.