Outputting from a multi select list

5 posts by 2 authors in: Forums > CMS Builder
Last Post: September 17, 2008   (RSS)

Hi Dave, Donna & all;

Thanks for all your great help, I have learned a lot from the forums however, I have searched the forums but was not able to find anything to help with this question.

I am trying to work on getting two lists to output content to a site. The first list - the user can only select one option so I have that one figured out, but the second list they can choose more than one option - can you help me edit the code so that the data is output depending on what checkboxes they have checked.

Here is the code I have so far
list($members_listingRecords, $members_listingMetaData) = getRecords(array(
'tableName' => 'members_listing',
'orderBy' => 'company_name',
'where' => 'category = "lodging"',
'where' => 'sub_category = "cottages"',
));


The first 'where' works well because they can only select one item, but the second 'where' for the sub-category does not display the members listings and I think it is because that is a multi select list and not a single check-box. Is there a way for this to work so they can select multiple sub-categories - like cottages & hotel and then show the same listing both on the Hotel page and the Cottages page?

Thank you for your help, Liz

Re: [Liz1001] Outputting from a multi select list

By Dave - September 10, 2008

Hi Liz,

There's currently no way to do "OR" searches without writing some custom code. So multi select searches aren't supported yet. You can combine the searches like this though:

'where' => ' category = "lodging" AND sub_category = "cottages" ',

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Liz1001] Outputting from a multi select list

By Dave - September 10, 2008

"Or" searching isn't automatically supported, no.

But can you post (or email me - dave@interactivetools.com) a link to your search form. I'll see if I can think of any simple solutions.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Outputting from a multi select list

Dave, thank you for the solution this worked well:

"Multi value checkboxes store their values in the database as a list separated by tabs. Try this MySQL to match a single value from the list of selected values:

'where' => 'category LIKE "%cottages%" ',

LIKE means "looks like" and % means "anything". So this matches text that starts with anything, then has cottages, then ends with anything."

Liz