Forum Moderators: coopster
I have a phonebook function where the user can enter a first name/surname etc. The form then accesses a database (through ODBC..not MySQL) that selects any records with matching details.
The problem I have is that most users enter details in lower case (I.e myname), and the entries on the database can be any case at all (I.e Myname or MyName).
Whats the best solution to this problem? I was thinking about changing both the input name and database name to upper case before comparing? If so, is there a php function to do this?
Many thanks :)
$string = strtolower($string); // make it lower case
$string = strtoupper($string); // make it UPPER case
$string = ucwords($string); // make it Upper Case First Letter
I believe that you can use a wildcard in your query and it will ignore case.
$sql = "SELECT * FROM table WHERE field LIKE 'C%' ";
I'm pretty sure this will return everything that begins with the letter C, irrespective of case.