如何将地址转换为Google Maps Link

1 php google-maps hyperlink

我有以下代码从数据库中提取地址。

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

并在管理区域上显示地址。

我希望使用以下方式将地址链接到Google地图

<a href="maps.google.com/?p= {then the addy} "> {the addy} </a>
Run Code Online (Sandbox Code Playgroud)

但是,当我将链接添加到代码中时,代码将中断。

最近的尝试是

<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>
Run Code Online (Sandbox Code Playgroud)

Kei*_*h A 5

您的代码很好,应该可以工作,只需将您的Google地址更改为https://maps.google.com/maps?q=