1
I have the following table in the database:
idUser - Username - Group
1 - John - 5GR
2 - Donate - 1GR
And the following query:
SELECT * FROM `table` WHERE `idUser` = '$name' OR `Group = '$name'
$name is the variable that contains the value you enter.
When the user enters 1, only the user with idUser=1 is shown. This is correct.
When the user enters 2, only the user with idUser=2 is shown. This is also correct.
The problem is when the user enters '1GR'.
The correct would be to display only the user with Group = 1GR, in this case the user Doe.
However the John user is also shown because his idUser = 1 and the string entered by the user contains 1. The problem is the comparison with idUser, I checked whether to remove this comparison from the query it presents correctly (however the user can no longer search for user id and this is essential).
Is there any way to fix this?