我想显示给定lat和long附近的所有点

时间:2017-08-30 07:51:59

标签: php

$ulat = $data['ULat'];
$ulong = $data['ULong'];

$sql = "SELECT PostId, (3959 * acos(cos(radians($ulat)) 
*cos(radians(LocationLat))* cos(radians(LocationLong) - radians($ulong)) + s 
in(radians($ulat))* sin(radians(LocationLat)))) AS distance FROM 
VehicleDetails HAVING distance < 2500 ORDER BY distance LIMIT 0, 20";


  $query = mysqli_query($con, $sql) or die('query fails');
  var_dump($query);

我只获得一行数据,即使距离为0.当我手动输入LocationLong和LocationLat的值时,它返回正确的距离,但是当变量如上所述通过时返回0。

我的输出:array(4){   [0] =&GT;   字符串(1)&#34; 1&#34;   [&#34;&帖子ID#34;] =&GT;   字符串(1)&#34; 1&#34;   [1] =&GT;   string(1)&#34; 0&#34;   [&#34;距离&#34;] =&GT;   string(1)&#34; 0&#34; }

0 个答案:

没有答案