Conditional to modify query results

here is the mysql query you can use to get the result having distance less then your value.

SELECT * , pm1.meta_value  as latitude, pm2.meta_value as longitude ,    
      (((acos(sin(([latitude]*pi()/180)) * 
          sin((pm1.meta_value * pi()/180)) + cos(([latitude]*pi()/180)) * 
          cos((pm1.meta_value * pi()/180)) * cos((([longitude] - pm2.meta_value)* 
          pi()/180))))*180/pi())*60*1.1515
      ) as distance

FROM wp_posts p
JOIN wp_postmeta pm1 ON pm1.post_id = p.ID AND pm1.meta_key = 'latitude'
JOIN wp_postmeta pm2 ON pm2.post_id = p.ID AND pm2.meta_key = 'longitude'
WHERE ID = 98
having distance < $_GET['within']

It will return all the post with distance is less then your $_GET[‘within’] value.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)