I have this little php search script to help me search through my users table.
Example:
- If I search for "John", I get results
- If I search for "John Doe" (two words with a space) I get no results. Even if the users name is John Doe.
I was wondering if there is something in this script I could change to help me search for multiple key words.
Here is the Search code:
<?php
if(isset($_GET['keywords'])){
$keywords = escape($_GET['keywords']);
$search = DB::getInstance()->query("
SELECT `id`,`username`,`first_name`,`last_name`,`unit`,`email`,`rent_own`,`city`,`zip`,`phone`,`joined`,`group_id` FROM `users` WHERE
`username` LIKE '%{$keywords}%' OR
`first_name` LIKE '%{$keywords}%' OR
`last_name` LIKE '%{$keywords}%' OR
`unit` LIKE '%{$keywords}%' OR
`email` LIKE '%{$keywords}%' OR
`rent_own` LIKE '%{$keywords}%' OR
`city` LIKE '%{$keywords}%' OR
`zip` LIKE '%{$keywords}%' OR
`phone` LIKE '%{$keywords}%' OR
`joined` LIKE '%{$keywords}%' OR
`group_id` LIKE '%{$keywords}%'
");
?>
Any thought or solutions are welcome and appreciated.