Advertisement
rAthus

[PHP/MySQL] Trier par latitude/longitude les plus proches

Nov 13th, 2014
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.27 KB | None | 0 0
  1. $latitude = 0; // latitude recherchée
  2. $longitude = 0; // longitude recherchée
  3. $query = 'SELECT *, SQRT(POW(ABS(ma_table.latitude-'.$latitude.')*40075.017/360,2)+POW(ABS(ma_table.longitude-'.$longitude.')*40007.864/360,2)) AS distance FROM ma_table ORDER BY distance ASC';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement