0

I've been trying to get my Email and URL to show up as hyperlinks with a href and mailto with no luck. Can someone take a look at the following code and let me know what I need to do? Thanks.

<?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/>';
    }

?>
1
  • I don't even see you trying anything like what you described in your question. Do you know any HTML? Commented Dec 6, 2012 at 1:11

2 Answers 2

3

As your Output is HTML simply write

echo '<br/> Email: <a href="mailto:'.$row['email'].'">'.$row['email'].'</a>';
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the help. That worked. I began learning PHP and MySQL last week and just now created a search box that grabs information from the database.
0

This should help you

echo "<br/><a href='mailto:".$row['email']."'>".$row['email']."</a>"

1 Comment

Double Quotes need more perfomance, and single quotes in HTML does not look nice - OK, we have a duplicate answer! ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.