I'm having a hard time searching my database with PHP code where I can search for an "item" but with more than one keyword.
For example: I have a bank that shelters main information such as ip's, username, etc. I was able to do a search code but only if I search with the desired IP, as I would to search by name and other information as well.
Follow 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?