Turn a search into a field that dials when clicking on a mobile phone

Asked

Viewed 36 times

0

I am developing a site with registration of local companies in PHP and Mysql with name, address and phone, so far so good, I am locked in the item where when they do a search on the site the result that returns in the table, where has the phone number and mobile would like to turn into a link so that it can be clicked and the same go to the cell phone dialer... like, if it’s 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 cell phone dialer, but I’m not able to do this 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 "cell phone?" are the ones I need to turn into link to dial... I just don’t know how to mount the code with <a href=tel>.

  • I believe this depends on the implementation of the browser, some smartphone applications can do this, such as mobile Gmail, it is not everywhere that will work

1 answer

1

You can include the data inside the tag <a>, riding in this way:

<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 no Ideone

  • It worked perfectly, thank you very much, for days that was locked in this blessed code... Even worth!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.