I am trying to use a like statement in the function format. I received a lot of results using mysql or pdo formats, but they didn't work for my format i have set up already. It's just not returning anything and I am not sure if this is the correct format. Here is what I have:
function search_users($namesearch){
global $db;
$query = "SELECT * FROM users
WHERE username LIKE '%:namesearch%'
ORDER BY username";
$statement = $db->prepare($query);
$statement->bindValue(":namesearch", $namesearch);
$statement->execute();
$usersearch= $statement->fetchAll();
$statement->closeCursor();
return $usersearch;
}