php - DBO Select where equals and like
I have tried writing the code below 100 different ways and cannot figure out the proper syntax. It seems no matter how I write this, the $loggeduser is not passed to the WHERE username. What am I doing wrong? What is the proper syntax?
$query = $db->prepare('SELECT * FROM sites WHERE username = ? AND name LIKE ? OR login LIKE ? AND category="te"'); $query->bindValue(1, $loggeduser); $query->bindValue(2, '%'.$_POST[search].'%'); $query->bindValue(3, '%'.$_POST[search].'%'); $query->execute();}