$lon=$lon*3.1415926535898 / 180.0;
$lat=$lat*3.1415926535898 / 180.0;
// 根据经纬来计算附近的好友
$sql = "select * ,(ROUND( (2 * asin(sqrt(pow(sin(('".$lat."'-(lat*3.1415926535898 / 180.0))/2),2)+cos('".$lat."')*cos(lat*3.1415926535898 / 180.0)*pow(sin(('".$lon."'-lon*3.1415926535898 / 180.0)/2),2))))* 6378.137 *10000)/10)as distance from pt_user where u_id!='".$u_id."' order by distance asc limit 0,50";
$lat=$lat*3.1415926535898 / 180.0;
// 根据经纬来计算附近的好友
$sql = "select * ,(ROUND( (2 * asin(sqrt(pow(sin(('".$lat."'-(lat*3.1415926535898 / 180.0))/2),2)+cos('".$lat."')*cos(lat*3.1415926535898 / 180.0)*pow(sin(('".$lon."'-lon*3.1415926535898 / 180.0)/2),2))))* 6378.137 *10000)/10)as distance from pt_user where u_id!='".$u_id."' order by distance asc limit 0,50";
其中 lon,lat 为数据库中的字段, distance 的值单位为(米)。经过简单测试没有问题。