SELECT
id, (
3959 * acos (
cos ( radians(60.0000) )
* cos( radians( lat ) )
* cos( radians( lng ) - radians(30.0000) )
+ sin ( radians(60.0000) )
* sin( radians( lat ) )
)
) AS distance
FROM markers
HAVING distance < 30
ORDER BY distance
LIMIT 0 , 20;
foreach($res as $line)
{
if(strlen($line) === 0 ) continue; //в лоб
if(!strripos($line, "<|>")) continue; //Но вот так наверно лучше будет.
$elem = explode("<|>",$line);
echo "<li><a href=".$elem[1]." target='_blank'>".$elem[2]."</a></li>";
}