Hey, I have a php file that pulls the info for a bands concert such as date, time, location etc. How could I go about pulling the location info and auto generate a link from that info for a google maps link..
Code reply posted below
Hey, I have a php file that pulls the info for a bands concert such as date, time, location etc. How could I go about pulling the location info and auto generate a link from that info for a google maps link..
Code reply posted below
For those of you that want to read the code
credentials xxx'd out... please dont provide authentication credentials
<?
$user = "xxxxx";
$pass = "xxxxx";
$dbh = mysql_connect("localhost", $user, $pass);
mysql_select_db('underwhe_site');
?>
<?php
$page_title = "SHOWS";
require("header.php");
?>
<p align="justify" class="style1 style4">SHOWS</p>
<?
if ($show) {
$sql = "SELECT DATE_FORMAT(date,'%c/%e/%Y'), venue_id, description FROM site_tourdates WHERE id=$show LIMIT 1";
$result = mysql_query($sql,$dbh);
$err = mysql_error();
if (mysql_num_rows($result) > 0) {
if ($err) { echo "$err"; die; }
list($date, $venue_id, $description) = mysql_fetch_array($result);
$sql2 = "SELECT name, street_address, city, state, zipcode, country, age_restriction, phone_number, more_info FROM site_tourdates_venues WHERE id=$venue_id LIMIT 1";
$result2 = mysql_query($sql2,$dbh);
$err = mysql_error();
if ($err) { echo "$err"; die; }
list($venue_name, $street_address, $city, $state, $zipcode, $country, $age_restriction, $phone_number, $more_info ) = mysql_fetch_array($result2);
echo "When: $date <br> Where: $venue_name <br> Details: $description <br> <br>";
echo "<u>Venue Details</u> <br> <br> $venue_name<br> <br>Address:<br>$street_address<br>$city, $state $zipcode<br>";
if ($country != 'US') echo "$country<br>";
if (!$phone_number) $phone_number="N/A";
echo " <br>Phone Number: $phone_number<br> <br>";
if ($age_restriction) echo "Age Restriction: $age_restriction +<br>";
if ($more_info) echo "More Info: $more_info";
}
else
{
echo "There are currently no shows";
}
}
else {
$sql1 = "SELECT site_tourdates.id, DATE_FORMAT(site_tourdates.date,'%c/%e'), site_tourdates.description, site_tourdates_venues.name, site_tourdates_venues.city, site_tourdates_venues.state, site_tourdates_venues.country FROM site_tourdates, site_tourdates_venues WHERE site_tourdates.venue_id=site_tourdates_venues.id AND site_tourdates.date>=NOW() ORDER BY site_tourdates.date";
$result1 = mysql_query($sql1,$dbh);
$err = mysql_error();
if (mysql_num_rows($result1) > 0)
{
if ($err) { echo "$err"; die; }
while (list($tourdate_id, $date, $description, $venue_name, $venue_city, $venue_state, $venue_country ) = mysql_fetch_array($result1)) {
echo "<b><a href=\"shows.php?show=$tourdate_id\">$date $venue_city, $venue_state - $venue_name</a> </b> <br> $description<br>";
}
if (mysql_num_rows($result1)) echo " <br> <br>";
}
else
{
echo "There are currently no shows";
}
}
?>
good looking out... didnt realize
I took the main link url from google maps... and then used the following values from the database in the spots that the URL called for each type of data
echo "<b><a href=\"http://maps.google.com/maps?q=$street_address+$city,+$state,+$zipcode\">
<u>View Map</u> </a>