My code displays a list of people and a search field at the top. everything works fine, including searching. but I need people to appear randomly. The problem is that when I use the ORDER BY rand () (or any other ORDER BY) my search stops working. when doing the search appears the error attributed to the $ 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');
}
?>