This is my code. This SQL Query works properly in phpmyadmin, it returns 2 hotels as I wanted, but in the php code, it returns all of my hotels. Why is this not working?
$search_text = "%". $search_text ."%";
$query = "SELECT name,country,province,town FROM Hotel WHERE country LIKE ? OR province LIKE ? OR town LIKE ? OR name LIKE ? ORDER BY name DESC";
$stmt = Database::$connection->prepare($query);
$stmt -> bind_param('ssss',$search_text , $search_text, $search_text, $search_text);
$stmt -> execute();
$result = $stmt -> get_result();
$searched = null;
$count = 0;
while($row = $result -> fetch_array(MYSQLI_NUM)){
$searched[$count][0] = $row[0];
$searched[$count][1] = $row[1];
$searched[$count][2] = $row[2];
$searched[$count][3] = $row[3];
$count++;
}
$stmt-> close();
return $searched;