1
I have a form that passes the query data and an external PHP file called busca.php
My problem is that I don’t get any php error to know the problem of it not finding the filter search. When I use the normal search it returns me all the values of the database.
What’s going on? Follow the code of the program, where q
is to receive the text field consulta
file consulta.php
:
if(isset($_POST['buscar'])){
$q = $con->real_escape_string($_POST['consulta']);
$query_Busca = "SELECT * FROM equipamento WHERE tombamento LIKE '%$q%'";
$Busca = mysqli_query($con,$query_Busca) or die($con->error);
// Check results
if($Busca){
//Se for um sucesso!
$row_Busca = mysqli_fetch_assoc($Busca);
$totalRows_Busca = $Busca->num_rows;
}
In this else
the function is working normal giving all the database data as wish the problem is even in the code above where I want to find the equipment only by the tipping number that is in "query" however it does not think and returns me error.
} else {
$query = "SELECT * FROM equipamento";
$Busca = $con->query($query) or die($con->error);
$row_Busca = mysqli_fetch_assoc($Busca);
$totalRows_Busca = $Busca->num_rows;
}
See if
$_POST['busca
] has some value and check if the query returns something, can give:print_r($row_Busca);
– rray
I put and I return nothing @lost, there appeared nothing, this right?
– DarkJontex
If I put this way in the if
$row_Busca = $Busca->fetch_assoc($Busca);
works, but he gives me that mistake:mysqli_result::fetch_assoc() expects exactly 0 parameters, 1
– DarkJontex
I don’t know if it helps, but
tombamento
is type INT ie, only number, this right the LIKE I put? What makes me curious is that no error.– DarkJontex
Like does not work with int fields.
– rray
what I use to compare then?
– DarkJontex