0

我一直试图让我的电子邮件和 URL 显示为带有 h​​ref 和 mailto 的超链接,但没有成功。有人可以看看下面的代码,让我知道我需要做什么吗?谢谢。

<?php
    mysql_connect ("localhost", "root", "")  or die (mysql_error());
    mysql_select_db ("store_location");

    $term = $_POST['term'];

    $sql = mysql_query("SELECT * 
                        FROM store_location 
                        WHERE store_name like '%$term%' 
                        OR address like '%$term%' 
                        OR city like '%$term%' 
                        OR state like '%$term%' 
                        OR zip like '%$term%' 
                        OR phone like '%$term%' 
                        OR fax like '%$term%' 
                        OR email like '%$term%' 
                        OR url like '%$term%' ");

    while ($row = mysql_fetch_array($sql)){
      echo '<h1>Search Results:</h1>';
      echo 'Store Name: '.$row['store_name'];
      echo '<br/> Address: '.$row['address'];
      echo '<br/> City: '.$row['city'];
      echo '<br/> State: '.$row['state'];
      echo '<br/> Zip: '.$row['zip'];
      echo '<br/> Phone: '.$row['phone'];
      echo '<br/> Fax: '.$row['fax'];
      echo '<br/> Email: '.$row['email'];
      echo '<br/> URL: '.$row['url'];
      echo '<br/><br/>';
    }

?>
4

2 回答 2

3

由于您的输出是 HTML,因此只需编写

echo '<br/> Email: <a href="mailto:'.$row['email'].'">'.$row['email'].'</a>';
于 2012-12-06T01:12:24.677 回答
0

这应该可以帮助你

echo "<br/><a href='mailto:".$row['email']."'>".$row['email']."</a>"
于 2012-12-06T01:12:54.800 回答