Turn a search into a field that you dial when clicking on the cell

0

I'm developing a site with local business registration in PHP and MySQL with name, address and phone, so alright, I'm stuck on the item where when doing a search on the site the result that return in the table, where it has the number phone and cell phone would like to turn it into a link so it can be clicked and the same go to the cellular dialer ... type, if it is a fixed number on the page I know what to put:

<a href="tel:12345678">12345678</a>

It transforms so that I can click and it goes to the mobile dialer, but I can not do that with the numbers that appear in the query:

<?php foreach($clientes as $cliente):?>
                    <tr>
                  <td><?=$cliente->nome?> </br>
                      <?=$cliente->endereco?></td>
                  <td><?=$cliente->telefone?>  
                      <?=$cliente->celular?></td>
              </tr>
                <?php endforeach;?>
            </table>

The fields "phone?" and cellphone?" are the ones that I need to make a link to dial ... I just do not know how to mount the code with <a href=tel> .

    
asked by anonymous 25.03.2018 / 21:38

1 answer

1

You can include the data within the <a> tag, by mounting this:

<table>
<?php foreach($clientes as $cliente):?>
    <tr>
       <td><?=$cliente->nome?> </br>
          <?=$cliente->endereco?></td>
       <td><a href="tel:<?=$cliente->telefone?>"><?=$cliente->telefone?></a>
          <a href="tel:<?=$cliente->celular?>"><?=$cliente->celular?></a></td>
       </tr>
<?php endforeach;?>
</table>

Demo on Ideone

    
26.03.2018 / 00:05