带有PHP变量的URL

时间:2016-05-11 07:12:32

标签: php html

在我的数据库表中,我尝试链接变量,这是我当前的代码

echo "<td>" . $row['formatted_ts'] . "</td><td>" . $row['marketer'] . "</td><td>" . $row['facility'] . "</td><td>" . $row['name'] . "</td><td>" . $row['type'] . "</td><td>" . $row['phone'] . "</td><td>" . $row['email'] . "</td><td>" . $row['fax'] . "</td><td>" . $row['description'] . "</td><td>" . $row['locality'] . "</td><td>" . $row['state'] . "</td><td>" . $row['zip'] . "</td><td>" .<a href="https://www.google.com/maps/place/<?php echo $row['latlng']; ?>"> Link </a> . "</td>";

我无法让链接正常工作。在上表中,它正在运作。

<td><a href="https://www.google.com/maps/place/<?php echo $row_leadstammy['latlng']; ?>"> Link </a></td>

3 个答案:

答案 0 :(得分:3)

你搞砸了一下html。尝试将每个单元格放在自己的行上,以便更容易找到解决方案

echo "<td>" . $row['formatted_ts'] . "</td>";
echo "<td>" . $row['marketer'] . "</td>";
echo "<td>" . $row['facility'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "<td>" . $row['phone'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['fax'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['locality'] . "</td>";
echo "<td>" . $row['state'] . "</td>";
echo "<td>" . $row['zip'] . "</td>";
echo "<td><a href=\"https://www.google.com/maps/place/" . $row['latlng'] . "\"> Link </a></td>";

答案 1 :(得分:0)

问题是因为您的锚标记附近有一些额外的单/双引号,echo中正在使用echo。请尝试以下代码:

echo "<td>" . $row['formatted_ts'] . "</td><td>" . $row['marketer'] . "</td><td>" . $row['facility'] . "</td><td>" . $row['name'] . "</td><td>" . $row['type'] . "</td><td>" . $row['phone'] . "</td><td>" . $row['email'] . "</td><td>" . $row['fax'] . "</td><td>" . $row['description'] . "</td><td>" . $row['locality'] . "</td><td>" . $row['state'] . "</td><td>" . $row['zip'] . "</td><td><a href='https://www.google.com/maps/place/". $row['latlng'] ."'> Link </a></td>";

OR

或者你可以按照以下方式进行操作,这一点很清楚。

echo "<td>" . $row['formatted_ts'] . "</td>
<td>" . $row['marketer'] . "</td>
<td>" . $row['facility'] . "</td>
<td>" . $row['name'] . "</td>
<td>" . $row['type'] . "</td>
<td>" . $row['phone'] . "</td>
<td>" . $row['email'] . "</td>
<td>" . $row['fax'] . "</td>
<td>" . $row['description'] . "</td>
<td>" . $row['locality'] . "</td>
<td>" . $row['state'] . "</td>
<td>" . $row['zip'] . "</td>
<td><a href='https://www.google.com/maps/place/". $row['latlng'] ."'> Link </a></td>";

答案 2 :(得分:0)

你已经处于回声中,即php,那你为什么要做<a href="https://www.google.com/maps/place/".$row['latlng']

只需使用:

echo "<td>" . $row['formatted_ts'] . "</td><td>" . $row['marketer'] . "</td><td>" . $row['facility'] . "</td><td>" . $row['name'] . "</td><td>" . $row['type'] . "</td><td>" . $row['phone'] . "</td><td>" . $row['email'] . "</td><td>" . $row['fax'] . "</td><td>" . $row['description'] . "</td><td>" . $row['locality'] . "</td><td>" . $row['state'] . "</td><td>" . $row['zip'] . "</td><td><a href="https://www.google.com/maps/place/".$row['latlng']."> Link </a></td>";

整个代码:

pip install pydotplus