Dave Smith
Dave Smith

Reputation: 31

make phone number clickable to dial screen on mobile?

How can i make a phone number that's being echoed in php from mysql database?

I'm new to php and mysql and still learning, please can someone explain or show me how to make a phone number clickable to go to the dialing screen on a mobile.

Here's the code im using below, i some how need to adapt the hyperlink aroung my '

<?php
$user_type_set = user_type_profile();
while ($user = mysql_fetch_array($user_type_set)) { ?>

<div class="contact-buddy"></div><div class="contact-buddy2"></div>
<div class="contact_details_phone"><p><strong>Phone: <div class="phone_font"><strong><?php echo $profile['contact_number'] ?></strong></div></div></p>
<div class="contact_details_email"><p><strong>Email:&nbsp;&nbsp;<?php echo $profile['public_email'] ?></strong></p></div>

<? } ?>

Upvotes: 2

Views: 10429

Answers (2)

John Dill
John Dill

Reputation: 15

If you want to make the phone number returned by <?php echo $profile['contact_number'] ?> clickable then you can use a straight HTML code block with inline PHP:

<a href="tel:<?php echo $profile['contact_number']; ?>"><?php echo $profile['contact_number']; ?></a>

Or clean it up a bit with this PHP:

<?php
$phone = $profile['contact_number'];
echo "<a href="tel:$phone">$phone</a>";
?>

Whichever method you want.

Upvotes: 0

Aaron
Aaron

Reputation: 21

This should definitely work on iphones, but I believe it would work for androids as well. Your php should output as it's final product something similar to:

<a href="tel:1-800-555-5555">1-800-555-5555</a>

Upvotes: 2

Related Questions