Where statement - List checkboxes (multi value)

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 9, 2012   (RSS)

Re: [crazyfish] Where statement - List checkboxes (multi value)

By gregThomas - October 9, 2012

Hi,

From what I understand your trying to get any records with at least one box ticked? I've found two ways you could do this in a getRecords function:

'where' => "CHAR_LENGTH(available) > 1"

This will check the length of the string stored in the available field, and if it has at least one charecter it will be returned. So it will return everything with at least on box ticked.

The second way is to do something like this:

'where' => "available LIKE '%available%' OR available LIKE '%prints%' OR available LIKE '%sold%'"

You could also have multiple LIKE statements that return every string that could be stored in the available field, you can add as many of these OR statements as you require.

Let me know if your looking for something different.

Thanks
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Where statement - List checkboxes (multi value)

By crazyfish - October 9, 2012

ha, simple problem solved.

Its NOT '%\tavailable\t%'",
but %available%

Thanks for your ideas, you guys rock.

PS yes I know I was vague as hell :)