I have a multiple select list called categories, with numeric values:
<select name="searchcats" multiple>
<option value=1>Item A
<option value=2>Item B
<option value=3>Item C...
I submit the form, searching the "categories" field, which is a comma delimeted list of numbers, (1,3,19,44) for example.
The following loop works well, but it's not what I want to do. If user selects option 1 and 2, only records with BOTH 1 and 2 in the comma delimited categories field will be found. I want all records with EITHER 1 or 2 in the categories field.
I'm probably being bone-headed here. Anyway, appreciate any help.
<cfloop list=#searchcats# index="x">
and ( categories like '#x#'
or categories like '%,#x#'
or categories like '#x#,%'
or categories like '%,#x#,%'
)
</cfloop>
<select name="searchcats" multiple>
<option value=1>Item A
<option value=2>Item B
<option value=3>Item C...
I submit the form, searching the "categories" field, which is a comma delimeted list of numbers, (1,3,19,44) for example.
The following loop works well, but it's not what I want to do. If user selects option 1 and 2, only records with BOTH 1 and 2 in the comma delimited categories field will be found. I want all records with EITHER 1 or 2 in the categories field.
I'm probably being bone-headed here. Anyway, appreciate any help.
<cfloop list=#searchcats# index="x">
and ( categories like '#x#'
or categories like '%,#x#'
or categories like '#x#,%'
or categories like '%,#x#,%'
)
</cfloop>