I am attempting to create a search function for user profiles on my site.
$search= $_POST['search'];
$res=mysql_query("SELECT * FROM ".TBL_USERS." WHERE username LIKE '$search%'");
This is the code I use. This will only work if you search something that matches the start of the result. Is there any way I can return values that have what i type as part of the username regardingless of upper or lower cases?
Thankyou
“%” is the wildcard, so if you also place it in front of your search string (like
%$search%) it will match $search anywhere in username.Use “LOWER” in SQL to make your username lowercase and “strtolower” in PHP to do the same, then execute the query to get case-insensitive results.
And as David Dorward said: read bobby-tables.com before you do anything else!!!