在 Google 地图 API 上显示 SQL 地址值

Displaying SQL address values onto Google Maps API

我是 PHP 和 MySQL 的新手,我正在尝试创建事件的主详细信息页面。母版页包含数据库中的所有事件以及简要说明,详细信息页根据 EventID 提供有关该特定事件的更多信息。

PHP 代码运行良好,并根据详细信息页面中的事件显示所有正确信息。但是从 google 添加了一个地图 link,我想从该特定事件的地址列中获取值,并在 map.I 上显示位置,知道在哪里输入代码Iframe,但我正在努力将任何地址值保存到变量中。

我将 link 下面的代码。任何建议或帮助将不胜感激(就像我说我对这一切都是新手所以请保持友好!):)

主页

include"connect-mysql.php";

$sql = "SELECT * FROM Events";
$result = mysqli_query($conn,$sql);

?>

<html>
<body>

<?php
while($row=mysqli_fetch_assoc($result))
{
echo "<br><br>Event name: " .$row["EventName"],
    "<br>Second Name: " .$row["EventDate"],
    "<br><a href=googleDetail.php?EventID=" .$row["EventID"]. ">Details</a>";

}

?>

</body>
</html>  

详情页

include"connect-mysql.php";


$ID = $_GET["EventID"];
$Add1 = $_GET["EventAddress1"];
$Add2 = $_GET["EventAddress2"];
$Add3 = $_GET["Postcode"];


$sql = "SELECT * FROM Events WHERE EventID = '$ID' ";
$result = mysqli_query($conn,$sql);

?>

<html>
<body>

<?php
while($row=mysqli_fetch_assoc($result))
{
echo "<br><br>Event Name: " .$row["EventName"],
     "<br>Event Date: " .$row["EventDate"],
     "<br>Address 1: " .$row["EventAddress1"],
     "<br>Address 2: " .$row["EventAddress2"],
     "<br>Postcode: " .$row["EventPostcode"];

     }

?>

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2393.598194202707!2d-1.2525729846387041!3d53.1353580799353!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4879967b2e53227b%3A0xf3a89e4d74b3556b!2sADDRESS GOES HERE!5e0!3m2!1sen!2suk!4v1487765096800" width="450" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

尝试以下希望对您有所帮助。

<?php
    $sql = "SELECT * FROM Events WHERE EventID = '$ID' ";
    $result = mysqli_query($conn,$sql);
    $row=mysqli_fetch_assoc($result);
    ?>
    <iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.it/maps?q=<?php echo $row['EventAddress1']; ?>&output=embed"></iframe>