my code is not working im doing something wrong , is it possible to use named parameters for the key. I am trying to make it to where i can assign a value to the variable part in my sql"where username = aaron " without hard coding it, if not how can this be accomplished please
$select = $conn->prepare("SELECT * FROM users WHERE :key = :username ") ;
$select->execute([":key"=> "username", ":username"=> 'aaron' ]) ;
It's not working because it's going to replace :key by "username" and not username so your query will end up being :
SELECT * FROM users WHERE 'username' = 'aaron'
SQL binding is originally made to replace variable (things that changes) and not constant (your column name in this example).
If you still want to do something like that, you will need to code something yourself and not use the ->execute method.