make phone number clickable to dial screen on mobile?

一笑奈何 提交于 2019-12-18 09:14:15

问题


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>

<? } ?>

回答1:


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>



回答2:


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.



来源:https://stackoverflow.com/questions/14784914/make-phone-number-clickable-to-dial-screen-on-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!