我有这个错误:致命错误:未捕获的错误:在第 15 行抛出的距离()#1 {main} 中的布尔值调用成员函数 fetch()我需要计算的是表中所有位置之间的距离,每个位置都是唯一的lat,并且long我定义了一个位置并对其进行排序 DESC 并获取照片和标题:id | Country | photo | p_latitude | p_longtitude1 japan 1.jpg 32.125 35.1232 Chian 2.jpg 56.125 50.1233 USA 3.jpg 42.125 90.123 function distance() { global $con; $lat1= 36.2048; $lang1= 138.2529; $query = 'SELECT *, CASE WHEN '. $lat1 .' = `p_latitude` && '. $lang1 .' = `p_longtitude` THEN 0 ELSE DEGREES(ACOS(SIN(RADIANS(`p_latitude`)) * SIN(RADIANS('. $lat1 .')) +COS(RADIANS(`lat`)) * COS(RADIANS('. $lat1 .')) * COS(RADIANS(`p_longtitude`-'. $lang1 .'))))* 69.09 END as distance FROM `posts` ORDER BY distance desc'; $resd = $con->query($query); while($row_ratessada= $resd->fetch()){ $post_rate= $row_ratessada['post_title']; echo "this is the title"." ".$post_rate; } }
- 2 回答
- 0 关注
- 90 浏览
添加回答
举报
0/150
提交
取消