1
how to put an if and Else in this code for when the search in the database does not return any value?
include_once("conexao.php");
$sql= "SELECT FROM tb_nome WHERE nome LIKE '$pesquisar%'";
$salvar = mysqli_query($conexao,$sql);
while ($linhas = mysqli_fetch_array($salvar){
echo "Nome: ".$linhas['nome']."<br>";
echo "Nome: ".$linhas['telefone']."<br>";
}
Use
mysql_num_rows($salvar)
, would look something likeif(mysql_num_rows($salvar) == 0){ //faça algo se não houver dados }else{/ /faça algo se houver dados }
– Mauro Alexandre
thank you so much for your help
– Rebeca Aguirrer