Good afternoon, I'm having a question about how I would click on the button to call a function in js and another in php?
I have a problem, I want a variable in the $ name case to receive the value that you type in an input, and when I click the button, check with db and return the results on the same page
<script type="text/javascript">
function fnome() {
$nome = document.getElementById('nome').value;
}
</script>
<button onclick="fnome()">Pega</button>
<?php
$sql = mysql_query("SELECT * FROM pedidos WHERE nome LIKE '%".$nome."%'");
$row = mysql_num_rows($sql);
if ($row > 0) {
while ( $linha = mysql_fetch_array($sql)){
$id = $linha['id'];
$nome = $linha['nome'];
$pedido = $linha['pedido'];
$valor = $linha['valor'];
echo "<br><br>ID: ". @$id;
echo "<br><strong>Nome: </strong>". @$nome;
echo "<br>Pedido: ". @$pedido;
echo "<br>Valor: ". @$valor ;
}
}
else {
echo "Desculpe nenhum pedido foi encontrado!";
}
?>