1
doesn’t bring what I want, someone can tell me what I’m missing by looking at the code?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sistema de busca interna com PHP/MySQL</title>
</head>
<body>
<form name="frmBusca" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?a=buscar" >
    <input type="text" name="palavra" />
    <input type="submit" value="Buscar" />
</form>
<?php
// Conexão com o banco de dados
$conn = @mysqli_connect("localhost", "usuario", "senha") or die("Não foi possível a conexão com o Banco");
// Selecionando banco
$db = @mysqli_select_db("produtos", $conn) or die("Não foi possível selecionar o Banco");
// Recuperamos a ação enviada pelo formulário
$a = $_GET['a'];
// Verificamos se a ação é de busca
if ($a == "buscar") {
    // Pegamos a palavra
    $palavra = trim($_POST['palavra']);
    // Verificamos no banco de dados produtos equivalente a palavra digitada
    $sql = mysqli_query("SELECT * FROM produtos WHERE nome LIKE '%".$palavra."%' ORDER BY nome");
    // Descobrimos o total de registros encontrados
    $numRegistros = mysqli_num_rows($sql);
    // Se houver pelo menos um registro, exibe-o
    if ($numRegistros != 0) {
        // Exibe os produtos e seus respectivos preços
        while ($produto = mysqli_fetch_object($sql)) {
            echo $produto->nome . " (R$ ".$produto->valor.") <br />";
        }
    // Se não houver registros
    } else {
        echo "Nenhum produto foi encontrado com a palavra ".$palavra."";
    }
}
?>
</body>
</html>


Error?
– Pedro Augusto
"don’t bring what I want" - OK! And what do you want it to bring? Tip: Improve your question to avoid closing, learn more here.
– Melissa
Doesn’t bring the information, it brings part of the code
– Rodrigo Ramos
Paste the error, "part of the code", which is showing. Check to see if you saved the file with extension
.php– Pedro Augusto
in the table, I left only one field, for testing, I wanted it to bring as a result select, let’s assume, the field is called id_test it will select, in this case the result should be 1. it had to give me this result in this field of html
– Rodrigo Ramos
I’ll take the mistake and leave it here.
– Rodrigo Ramos
I had not made the mistake, because I wanted to see if there was something wrong with the code itself, something senseless, but I will put the error, just a moment.
– Rodrigo Ramos