If.. Contains...

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

By Toledoh - June 17, 2012

Hi Guys,

I want to do something like:
<?php if ($record['product_group'] == 4): ?>, but where I have multi-values, I miss out on items that equal "3 and 4".

I've tried:
<?php if ($record['product_group'] LIKE '4'): ?> and
<?php if ($record['product_group'] LIKE '%4%'): ?> but keep getting errors...

Any advice?
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] If.. Contains...

By robin - June 18, 2012

Hey Tim,

It looks like you're using data from getRecords()? If so, CMS Builder will have made 2 arrays for you from the multi-record field that you can use for easy php comparison.

$record['product_group:values'] and $record['product_group:labels']

To see if "4" is in the product group values array you can use this:
<?php if (in_array('4', $record['product_group:values'])): ?>

Hope that helps,
Robin
Robin
Programmer
interactivetools.com