I have a small table with just few columns, one of them is storing the information about the Category as an INT (just a simple number) eg.
id | name | category
11 | one file | 1
15 | some other file | 2
When displaying the data accross the site, I simply convert the category's number with the value stored in the PHP array:
$swm_array = array(
'1' => 'Electrical',
'2' => 'HVAC',
'3' => 'Plumbing',
);
When searching the table using LIKE operator, I can easily find the category if I type a number. What I need is to actually type in the category's value, and not its key and then find it against the entries in the table. I've been trying to include the array to the search using completely weird stuff, but to no vail.
Found here, in these forums, a lead: implode INSIDE the query but I was not able to pull it.
If you guys could help me out here, I'd be eternally grateful :)
My SQL query:
SELECT DISTINCT
`swm_id`,
`name`,
`desc1`,
`category`,
`file`
FROM
`swims`
WHERE
(
`name` LIKE '%".$q."%'
OR `desc1` LIKE '%".$q."%'
OR `file` LIKE '%".$q."%'
OR `swm_id` LIKE '%".$q."%'
**OR `category` LIKE '%".$q."%'**
)
AND `active` = '1'
Thanks, a lot!
Regards, Greg