= 100 AND `distance` <= '$maxdist' ORDER BY `distance`"; } else { $query = "SELECT ROUND(6378.137 * ACOS((SIN(PI() * $loc[lat] / 180) * SIN(PI() * `locations`.`lat` / 180)) + (COS(PI() * $loc[lat] / 180 ) * COS(PI() * `locations`.`lat` / 180) * COS(PI() * `locations`.`long` / 180 - PI() * $loc[long] / 180))), -1) AS `distance`, `locations`.`name` AS `location`, concat(`users`.`fname`, ' ', LEFT(`users`.`lname`, 1)) AS `name`, `long`, `lat`, `users`.`id` as `uid`, `contactinfo` FROM `locations`, `users`, `notary` WHERE `users`.`locid` = `locations`.`id` AND `users`.`id` = `notary`.`to` AND `users`.`listme` = 1 GROUP BY `notary`.`to` HAVING SUM(`notary`.`points`) >= 100 AND `distance` <= '$maxdist' ORDER BY `distance` LIMIT 50"; } $res = mysql_query($query); ?> 35) $points = 35; ?>
km