Im fairly new to PHP and MySQL and I am attempting to create a master detail page of events. The master page contains all of the events within the database with brief descriptions and the details page gives more information about that specific event based on the EventID.
The PHP code runs fine and displays all the correct information based on that event in the details page. However have added a map link from google and I want to take the values from the address column for that specific event and display the location on a the map.I know where to enter the code into the Iframe but I'm struggling to save any of the address values into a variable.
I'll link the code below. Any advice or help would be greatly appreciated (like I said I am new to all this so please be nice!) :)
Master page
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>
Detail page
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>
Try below hope this helps.
<?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>