Search code examples
phpgoogle-mapshyperlink

How to convert an address into a Google Maps Link


I have the following code that is pulling an address in from a database.

 <td class="center"><?php echo ($customer->address!='')?$customer->address:'NA';?></td>

And displaying the address on an admin area.

i would like the address to be linked to google maps using

<a href="maps.google.com/?p= {then the addy} "> {the addy} </a>

But when i add the link to the code the code breaks.

The most recent attempt was

<td class="center"><a href="http://map.google.com/?p=<?php echo ($customer->address!='')?$customer->address:'NA';?>"><?php echo ($customer->address!='')?$customer->address:'NA';?></a></td>

Solution

  • your code is fine and should work just change your google address to https://maps.google.com/maps?q=