Hi All, I have a problem when using multiple wheres
in the code below is a query, I need to return the value if it meets like name, like number or like group
It also must be user_access
When i run i get the results of the else but when searching (the first query) i get
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
on line if(mysqli_num_rows($result) > 0)
Any help is appreciated
$output = ‘’;
$user_name = “bob”;
if(isset($_POST[“query”]))
{
$search = mysqli_real_escape_string($connect, $_POST[“query”]);
$query = "
SELECT * FROM contacts WHERE user_access LIKE ‘%".$user_name."%’
WHERE name LIKE ‘%".$search."%’ OR number LIKE ‘%".$search."%’ OR member LIKE ‘%".$search."%’
";
}
else
{
$query = "
SELECT * FROM contacts WHERE user_access LIKE ‘%".$user_name."%’ ORDER BY name LIMIT 5
";
}
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
$output .= ’
Name | Number | Group | |
---|---|---|---|
'.$row["name"].' | '.$row["number"].' | '.$row["member"].' |