0
I’m having trouble searching my database with the PHP code where I can search for an "item" but with more than one keyword.
For example: I have a database in which I shelter key information such as ip’s, user names etc. I was able to make a search code but only if I search with the desired IP, as I would also search by name and other information.
Follows my code:
<?php
$buscar = $_POST['pesquisar'];
$sql = mysqli_query($conn, "SELECT * FROM principal WHERE ip LIKE '%".$buscar."%' ");
$row = mysqli_num_rows($sql);
if($row > 0){
while($linha = mysqli_fetch_array($sql)){
$ip = $linha['ip'];
$nome = $linha['nome'];
$setor = $linha['setor'];
$idpc = $linha['idpc'];
$tag = $linha['tag'];
$modelo = $linha['modelo'];
$tipo = $linha['tipo'];
$so = $linha['so'];
$observacao = $linha['observacao'];
echo "<strong>IP: </strong>".@$ip;
echo "<br /><br />";
echo "<strong>NOME: </strong>".@$nome;
echo "<br /><br />";
echo "<strong>SETOR: </strong>".@$setor;
echo "<br /><br />";
echo "<strong>IDPC: </strong>".@$idpc;
echo "<br /><br />";
echo "<strong>TAG: </strong>".@$tag;
echo "<br /><br />";
echo "<strong>MODELO: </strong>".@$modelo;
echo "<br /><br />";
echo "<strong>TIPO: </strong>".@$tipo;
echo "<br /><br />";
echo "<strong>SO: </strong>".@$so;
echo "<br /><br />";
echo "<strong>OBSERVAÇÃO: </strong>".@$observacao;
echo "<br /><br />";
}
}else{
echo "Não há nenhum usuário registrado!";
}
?>
Could you help me?
In the $search variable, the user is typing only by IP or has more parameters?
– Vinicius Gabriel
You want to recover bank records according to your
$buscar
and this can be an IP, Name or other information ? That ? If so, tried to use aOR
in your select ?– 8biT