If statement with checkbox multivalue...

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 11, 2013   (RSS)

By gregThomas - April 10, 2013 - edited: April 10, 2013

Hi Sean,

A multivalue checkbox field stores the values in it in a tab separated string. This is the best way to check if a value is stored in it:

  <?php if( strstr($staffRecord['section'],"\tMakeup\t")): ?>
    Make up is checked
  <?php endif; ?>

So I'm using the PHP strstr function to search if Makeup is in the string. The \t characters will add tabs to the search string to ensure values that contain Makeup don't trigger the the if statement as well.

Thanks

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By crazyfish - April 11, 2013

Thank you!