As for a variable term in a link?

0

I would like to know how to in a link a variable?

http://201.76.188.6:8090/call.php?exten=7601&number=[celular]

I'm doing this: (did not work)

<!doctype html>
<html>
<head
    <meta charset="utf-8">
    <title>Documento sem título</title>
</head>
<body>

<?php
include ('conexao.php');
$query = "SELECT 'ddd', 'celular' FROM 'Cliente' WHERE 1 " ;
$meliga = "$ddd, $celular" ;
?>

<script>
var numero = "<?php echo $meliga; ?>";
</script>

<a href="#" onclick="window.open('http://201.76.188.6:8090/call.php?exten=7601&number=' + numero)" target"_blank">Me Ligue</a>

</body>
</html>
    
asked by anonymous 21.12.2018 / 19:05

3 answers

0

Good afternoon, I did not understand the purpose of the page, but I gave a corrected some errors of syntax or logic itself, take a look there.

<?php
include ('conexao.php');
$query = "SELECT 'ddd', 'celular' FROM 'Cliente' WHERE 1 " ;

//Se a conexão for com PDO
$result = $query->execute();
$meliga = $result['ddd'].$result['celular'];

?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>Documento sem título</title>
</head>
<body>

    <a href="http://201.76.188.6:8090/call.php?exten=7601&number=<?= $meliga ?>" target="_blank">Me Ligue</a>

</body>
</html>

However, the method that takes the query response is wrong.

    
21.12.2018 / 20:48
0

Look at a test I did.

In the test file you make the query and save the number that you want to go to the url in the variable $meliga ;

File: teste.php

<?php
/* A consulta no banco de dados retornou:
** array{
**  [ddd]=>"99",
**  [numero]=>"99999-9999"
** }
*/

$meliga="9999999-9999"; 
?>
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <a href="link.php?number=<?= $meliga; ?>">Ligar</a>
</body>
</html>

Link.php file:

<?php
    echo $_GET['number'];
?>

Test there and see if it helps.

    
26.12.2018 / 18:18
-1

See if it helps:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Documento sem título</title>
</head>
<body>

<script>
function changeURL(numero) {
    document.getElementById("link").href = "http://201.76.188.6:8090/call.php?exten=7601&number=" + numero;
}
</script>
<form action="javascript:void(0);">
<input type="text" name="phone" onkeypress="changeURL(this.value)"/>
<a id="link" href="http://201.76.188.6:8090/call.php?exten=7601&number=" onclick="javascript:alert(this.href); return 0;">Me Ligue</a>
</form>
</body>
</html>
    
21.12.2018 / 19:48