Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

turning mysql query result into hyperlink

Status
Not open for further replies.

rjseals

Technical User
Joined
Nov 25, 2002
Messages
63
Location
US
Hello,
I have a Mysql database that has user names, phone numbers and email addresses, location etc.

eg

John Smith | 333-3434 | jsmith@aol.com | Denver
mary smith | 343-2232 | msmith@aol.com |Chicago

I run a query that returns users information based on their location.
So:


?>
$sql = "Select Full_Name, Location, Phone, Email from table where full_name like '%$name%' order by Last_Name";
?>


I put that into an array:

<?
$result = mysql_query($sql);

for ($count = 1; $row = mysql_fetch_row ($result); ++$count)
{
$fullname=$row[0]; //puts results into variables
$location=$row[1];
$Phone=$row[2];
$Email=$row[3];

//prints out variables
print '<table border = &quot;1&quot;>';
print '<tr>';

print '<td width = &quot;2%&quot; align = &quot;left&quot;> <font size=&quot;2&quot;><b>'.$fullname.'</font></td> ' ;
print '<td width = &quot;1%&quot; align = &quot;center&quot;> <font size=&quot;2&quot;><b>'.$location .'</font></td> ';
print '<td width = &quot;1%&quot; align = &quot;center&quot;> <font size=&quot;2&quot;><b>'.$phone .'</font></td> ';
print '<td width = &quot;3%&quot; align = &quot;center&quot;> <font size=&quot;2&quot;><'.$email .'</font></td>';

print '</tr>';
print '</table>';

}
?>


This is all fine and good but I want to turn the email address into a hyperlink for that email address.

I tried:

.....

<?
print '<td width = &quot;3%&quot; align = &quot;center&quot;> <font size=&quot;2&quot;><a href =&quot;mailto:'.$email .'&quot;></a></font></td>';
?>

.....
but that doesnt work. Can this be done />
Thank you.
 
Luckily this is an easy one.
You left out the text to click on:
Code:
<? 
print '<td width = &quot;3%&quot; align = &quot;center&quot;> <font  size=&quot;2&quot;><a href =&quot;mailto:'.$email .'&quot;>
Code:
Link text here
Code:
</a></font></td>'; 
?>

That should be it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top