I need to get my if

Asked

Viewed 41 times

-2

I’m doing a website search in the bank and I have the following code

<?php
include("conexao.php");

$pesquisar = $_POST['pesquisar'];
$result_produtos = "SELECT * FROM produtos WHERE nome LIKE '%$pesquisar%' LIMIT 5";
$resultados_produtos = mysqli_query($conexao, $result_produtos);


if($pesquisar == ""){
    echo "1"
;}else if($pesquisar != $result_produtos){
    echo "2"
;}else{
    while($rows_produtos = mysqli_fetch_array($resultados_produtos)){
        echo "O produto: ".$rows_produtos['nome']."<br>"
        ;}
    ;}
?>

the $pesquisa comes from a input on the form

  • when it’s empty it has to appear 1
  • if you are wrong appears 2
  • if you are in the bank item

On the bench there’s only the field arroz, but when I write arroz he’s showing up 2

1 answer

-2

instead of using a = no if statment, try using a .contains or .equals

Browser other questions tagged

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