我在phpadmin上创建了一个数据库,并且我已经从xml文件中提取信息到数据库,我的数据库字段由时间,纬度,经度,深度和大小组成。我有一个表格显示所有在网页上的信息,我有一个字段包含一个链接,而点击链接,它应该指示我一个谷歌地图API,它必须从数据库中提取纬度和经度信息,我有问题自动传递纬度和经度的值,任何help.here的我的代码使用href传递值
<?php
require('dbconnect.php');
$query="SELECT * from earthquake_xml";
$result= mysqli_query($dbc,$query);
echo "Query Executed Successfully ";
$numRow =mysqli_num_rows($result);
echo "<br> Number Of Rows:".$numRow;
?>
<!DOCTYPE HTML>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
padding:10px;
}
table{
border-collapse: collapse;
text-align:center;
}
</style>
</head>
<body>
<table>
<tr>
<td>Time</td>
<td>Latitude</td>
<td>Longitude</td>
<td>Depth</td>
<td>Magnitude</td>
<td>Google Map </td>
</tr>
<?php
if($numRow>0)
{
while($row=mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td>" .$row['Time'] . "</td>";
echo "<td>" .$row['Latitude']. "</td>";
echo "<td>" .$row['Longitude']. "</td>";
echo "<td>" .$row['Depth']. "</td>";
echo "<td>" .$row['Magnitude']. "</td>";
echo "<td><a href='googleMap.php?longitude= '' '>Click here</a></td>";
echo "</tr>";
}
}
?>
</table>
</body>
</html>
这是我googleMap.php
<!DOCTYPE HTML>
<HTML>
<head>
<title></title>
<style>
html,body{
height:100%;
margin:0;
padding:0;
}
#map{
height:100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
function initMap(){
var myLatLng={lat:-36.5806,lng:-73.6355};
var map=new google.maps.Map(document.getElementById('map'),{
center:myLatLng,
zoom:8
});
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
var pos={
lat:-36.5806,
lng:-73.6355
};
var marker=new google.maps.Marker({
position:pos,
map:map,
});
map.setCenter(pos,marker)
},function(){
handleLocationError(true,map.getCenter());
});
}else{
handleLocationError(false,map.getCenter)
}
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=&callback=initMap">
</script>
</body>
</html>
你最好从问题中删除你的API密钥。 –