You need to calculate the distance from one lat/long position compared to another. Once this distance is calculated you can then compare it to your maximum radius. One algorithm to do this is the Haversine formula.
You will be able to find many implementations of this across the internet, here is the one in PHP.
function getDistance($latFrom, $longFrom, $latTo, $longTo)
{
$dLat = deg2rad($latTo - $latFrom);
$dLon = deg2rad($longTo - $longFrom);
$angle = sin($dLat / 2) * sin($dLat / 2) + cos(deg2rad($latFrom)) * cos(deg2rad($latTo)) * sin($dLon / 2) * sin($dLon / 2);
$c = 2 * asin(sqrt($angle));
$distance = 6371000 * $c;
// Distance is in metres
return $distance;
}
See (snippet above derived and basically the same): How to check if a certain coordinates fall to another coordinates radius using PHP only
Pass in your center lat/long and the records lat/long to get the distance in metres and then compare it:
if (getDistance(0, 0, 0, 0) < 1000) {
// do stuff
}
Where 1000
is your radius.