-2

I have a table with data issued from a PHP request, I want to make phone numbers clickable to allow passing a call if used with mobile device, and if possible to make the whole cell clickable.

My actual PHP code is:

while($row = mysql_fetch_array($result))
{
echo "<tr>";

    echo "<td align='center'>" .$row['name']. "</td>";      
    echo "<td align='center'>" .$row['phone']. "</td>";

echo "</tr>";

  }
  echo "</table>";
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Moatez
  • 771
  • 1
  • 6
  • 4
  • should try researching issues like this yourself first. This is not hard to find information in a web search – charlietfl Dec 20 '14 at 19:21

1 Answers1

1

you have to insert an anchor tag

inside the link you can use the tel: or callto: to use the auto dial functions more info in How to mark-up phone numbers?

for you code

while($row = mysql_fetch_array($result))
{
echo "<tr>";

    echo "<td align='center'>" .$row['name']. "</td>";      
    echo "<td align='center'><a href='tel:" . $row['phone'] . "'>" .$row['phone']. "</a></td>";

echo "</tr>";

  }
  echo "</table>";
Community
  • 1
  • 1
ManZzup
  • 526
  • 4
  • 12
  • Placing an anchor around a td isn't valid HTML. A better solution is to link the text (phone number) inside the td. If needed you can add `display:block; width: 100%;` to the anchor. – vicente Dec 20 '14 at 19:06
  • ah my bad, i didnt focus much on where im putting the anchor :) Ill do an edit – ManZzup Dec 20 '14 at 19:08