<?php
$query_getf = "select ci.tb_ci_id, concat(ci.tb_ci_fname, ' ',   ci.tb_ci_lname),ci.tb_ci_city, ct.tb_ct_desc, md5(ci.tb_ci_id), s.tb_s_name_full, case ci.tb_ci_addr_2 when '' then 
ci.tb_ci_addr_1 else concat(ci.tb_ci_addr_1, ', ', ci.tb_ci_addr_2) end, ci.tb_ci_phone_1, ci.tb_ci_phone_2, ci.tb_ci_fax, ci.tb_ci_email FROM tb_contact_info ci, tb_contact_type ct, tb_states s WHERE md5(ci.tb_p_id)='".$fd_p_d['md5_id']."' AND ci.tb_ct_id=ct.tb_ct_id AND ci.tb_s_id=s.tb_s_id ORDER BY ct.tb_ct_desc, ci.tb_ci_date_added";

//print $query_getf;

$sth_getf = mysql_query($query_getf);

if ($arr_getf = mysql_fetch_array($sth_getf)) {

    print '

     <td colspan="4" align="left" valign="top">

       <table width="100%" border="0" cellpadding="1" cellspacing="1">
  ';

          do {
               print '
               <tr>
          <td align="left" valign="top" class="text-11">                                      

This email is not showing up as a hyperlink. Any suggestions or ideas?

                  Email: '.$arr_getf[10].'
                                      </td>
                                <tr>
      <td colspan="4"><hr /></td>
</tr>
        ';
}while($arr_getf = mysql_fetch_array($sth_getf));
                                print '

        </table>
   </td>
 ';
}
else {

Dani AI

Generated

A few quick checks that usually solve this.

  • Look at the page source (or use DevTools) to confirm whether an actual anchor tag is being emitted. If you see the email only as text in the source, the PHP isn’t outputting a link. If an anchor is present but looks like plain text, CSS rules (for example a { text-decoration:none; color:inherit; }) can make links look like normal text.
  • In the posted snippet there is a mismatched table tag (<tr> where </tr> should be). Fixing malformed HTML can restore expected rendering. Also avoid fragile numeric indexes (like $arr_getf[10]) — use associative keys so you are certain you are accessing the email field.

Validate and escape before printing. Example:

$email = $row['tb_ci_email'] ?? '';
if ($email && filter_var($email, FILTER_VALIDATE_EMAIL)) {
  $safe = htmlspecialchars($email, ENT_QUOTES, 'UTF-8');
  // $safe is safe to insert into HTML; then wrap it in a link when printing
}

Use filter_var to ensure the value is a valid email and htmlspecialchars to prevent XSS. See the docs for details: filter_var and htmlspecialchars.

If spam is a concern (as warned), prefer a contact form or client-side obfuscation. A simple pattern that avoids putting the full address in the HTML source is to keep user/domain in data attributes and build the link with JavaScript:

<span class="email" data-user="john" data-domain="example.com"></span>

<script>
document.querySelectorAll('.email').forEach(function(el){
  var u = el.dataset.user, d = el.dataset.domain, e = u + '@' + d;
  el.innerHTML = '<a href="mailto:' + e + '">' + e + '</a>';
});
</script>

Also consider the suggestions from and but move away from deprecated mysql_* calls; use prepared statements with PDO or mysqli and fetch associative arrays for clarity.

Recommended Answers

All 3 Replies

I would not suggest showing E-Mail addresses at all ever on a website as these can be picked up by less than wholesome people :)

But if you really want to do this, echo an add the a mailto to the code around the email address.

I would not suggest showing E-Mail addresses at all ever on a website as these can be picked up by less than wholesome people :)

But if you really want to do this, echo an add the a mailto to the code around the email address.

To create an email link, you use the protocol, mailto:

eg:

<a href="mailto:user@example.com">user@example.com</a>

http://www.w3.org/TR/WD-html40-970708/htmlweb.html

You could also add a subject, see link.

Member Avatar for Member #117553

Well, here you should do some coding before printing the contents:...

//this is where you need to intervene

if ($arr_getf = mysql_fetch_array($sth_getf)) {
 
    print '....'

instead, do it like this

$result = mysql_fetch_assoc($sth_getf);
if(isset($result) && if_key_exists('tb_ci_email', $result))
  {
  $newemail = '<a href="mailto:'.$result['tb_ci_email'].'">'.$result['tb_ci_email'].'</a>';
  $result['tb_ci_email'] =$newemail;
  reset($result);
  }
if($result)
  {
   print( '
 
     <td colspan="4" align="left" valign="top">
 
       <table width="100%" border="0" cellpadding="1" cellspacing="1">
  ';
 
          do {
               print '
               <tr>
	      <td align="left" valign="top" class="text-11">	.....');
  }

Hope it works for you. Once you have it set, please tell us the result.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.