我有点奇怪的问题。我在我的 php.ini 中获取地方的纬度和经度。demo经纬度是这样的
Latitude 20º 24.002' N
Longitude 87º 18.135' W
问题是因为º
没有检索到数据。如何获得纬度º
?
这是我的查询
$sql = "select * from tbl_site where sit_id =".$_GET[id];
获取数据后,我有这个数组: -
{"item":{"sit_id":"3","sit_title":"title","sit_image":"img2.jpg","sit_zon_id":"1","sit_access":"Boat","sit_rating":"5","sit_experience":"all divers","sit_latitude":null,"sit_longitude":null}}
从数据库获取并解析为 JSON 的代码:
$dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $dbh->prepare($sql);
$stmt->bindParam("id", $_GET[id]);
$stmt->execute();
$employee = $stmt->fetchObject(); $dbh = null;
echo '{"item":'. json_encode($employee) .'}';