user5923290
user5923290

Reputation:

How to add phone numbers from database to <a href="tel:"> tag

<a href="tel:<?php echo $b2b_mec_num; ?>"><button type="button" class="btn" id="CallBtn">&nbsp;CALL</button></a>

I need to add phone numbers from database to the anchor tag above. How do I do that?

Edit from Comment:

$sql_m="select * FROM b2b_mec_tbl where b2b_shop_id=$b2b_shop_id"; // tracking table $sql_mec=mysqli_query($con,$sql_m) or die(mysqli_error());
$row_mec=mysqli_fetch_array($sql_mec);
$b2b_mec_num=$row_mec['b2b_mobile_number_1'];

Upvotes: 0

Views: 455

Answers (1)

Ryan Churchill
Ryan Churchill

Reputation: 81

You were close here is how I would do it.

<?php 
$con='DBCONNECT STRING HERE';
$sql_m="select * FROM b2b where b2b_id = '$b2b_id'";
$sql_mec=mysqli_query($con,$sql_m) or die(mysqli_error());

while($row_mec=mysqli_fetch_array($sql_mec)){ 
  $b2b_mec_num=$row_mec['b2b_mobile'];
}
?>

<a href="tel:<? echo $b2b_mec_num; ?>">
  <button type="button" class="btn" id="CallBtn">
    &nbsp;CALL
  </button>
</a>

Upvotes: 1

Related Questions