0
The code below returns some value, when there are several records with the same or similar name, when there is only one record in the bd does not return the value of that record.
<?php
include_once '../../Modulos/Database/Banco.php';
$pesquisa=$_POST['pesquisa'];
echo ($pesquisa);
$sql = "select * from fornecedor where razaoSocial like '%$pesquisa%' or nomeFantasia like '%$pesquisa%';";
$salva = mysqli_query($conexao, $sql);
if ($resultado = mysqli_fetch_array($salva)) {
while ($resultado = mysqli_fetch_array($salva)) {
$id = $resultado[0];
$razaoSocial = $resultado[1];
$cnpj = $resultado[2];
$nomeFantasia = $resultado[3];
$tel = $resultado[4];
$contato = $resultado[5];
$email = $resultado[6];
//$dataCadastro = $resultado[6]
// testando a função edita.php
//começará com 0 e vai evoluindo, isso também pode registrar quantas resultados tem a tabela
$parimpar++;
//A tabela do sbadmin precisa marcar com par ou ímpar cada linha
if ($id % 2 == 0) {
$parimpar = "odd";
} else {
$parimpar = "even";
}
//echo"<tr><th>$id</th><th>$nome</th><th>$codBarra</th><th>$descricao</th><th>$vCusto</th><th>$vVenda</th></tr>";
echo'
<tr class="' . $parimpar . ' gradeX">
<td><a href="cadastrarPedido.php?id=' . $id . '">' . $id . '</a></td>
<td>' . $razaoSocial . '</td>
<td>' . $cnpj . '</td>
<td>' . $nomeFantasia . '</td>
<td class="center">' . $tel . '</td>
<td class="center">' . $contato . '</td>
<td>' . $email . '</td>
</tr>';
}
} else {
echo ("Problema ao realizar a consulta n banco de dados" . mysqli_error($conexao));
}
mysqli_close($conexao);
?>
In this particular case you are saying that it does not return the value to variable
$sql
has what value ? You can consult withvar_dump($sql);
– Isac
string(87) "select * from supplier Where razaoSocial like '%new%' or namFantasia like '%new%';"
– Patrick Souza
Do you have any record with
razaoSocial
ornomeFantasia
withnovo
? When you perform this query on phpMyAdmin get some result?– Isac
Yes, I only have one record with new nameFantasia and phpmysadmin works correctly. In this table I have several testName and code is working when the survey is test.
– Patrick Souza