简体   繁体   中英

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>

<? } ?>

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM