【发布时间】:2017-03-14 05:13:16
【问题描述】:
这是我动态获取特定纬度地址的代码 来自 db.If 我使用这个静态值它工作正常。但如果我用 $latlong 这个变量来获取动态值。它显示错误。 有什么解决方案。请帮助我。
注意:未定义的偏移量:C:\xampp\htdocs\demo_calLatLong\calLatLong.php 第 21 行中的 0 注意:尝试在第 21 行获取 C:\xampp\htdocs\demo_calLatLong\calLatLong.php 中非对象的属性
<table class="table table-bordered">
<thead>
<tr>
<th>Client Name</th>
</tr>
</thead>
<?php
include 'db.php';
$sql = 'SELECT * FROM `location`';
$travel = mysqli_query($conn,$sql);
while ($row = mysqli_fetch_array($travel))
{?>
<tbody>
<tr class="active">
<?php
$latlong = $row[1].','.$row[2];
$geocode=json_decode(file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng=19.0978,22.8972&sensor=false',true));
?>
<td><?php echo $geocode->results[0]->formatted_address;?></td>
</tr>
</tbody>
<?php }?>
</table>
【问题讨论】:
标签: php mysql json file-get-contents geocode