1
My code displays a list of people and a search field at the top. everything works normal, including the search. But I need people to show up at random. The problem is that when I use ORDER BY Rand() (or any other ORDER BY) my search stops working. when searching appears the error assigned to $result.
<?php require_once("conecta.php"); ?>
<?php
//consulta dos dados
$assistentes = "SELECT * FROM assistentes ORDER BY rand() ";
if(isset($_GET["buscauser"])){
$nomebusca = $_GET["buscauser"];
$assistentes .= " WHERE nome LIKE '%{$nomebusca}%' OR sobrenome LIKE '%{$nomebusca}%' OR cidade LIKE '%{$nomebusca}%' ";
}
$resultado = mysqli_query($conecta, $assistentes);
if (!$resultado){
die('Falha na conexao com o banco');
}
?>
'Failed connection to bank' - assigned to ! $result
– Tom Zé