EXCLUDING A VALUE From a Checklist

6 posts by 2 authors in: Forums > CMS Builder
Last Post: January 26, 2018   (RSS)

By csdesign - January 26, 2018


Can someone please tell me how to exclude a value from a checklist?  I'll explain: 

I have a list of Stallions.  Each stallion has a checkbox list so mark all things relevant to that stallion.  ( ie:  New, Hunter, Jumper, Dressage, Pony, Archived )

I've been using this code for the listing to just list one value from the checklist (ie: Archived ) - which creates a list of all Archived Stallions on a single page. 

<?php $count = 0; ?>
<?php foreach ($stallion_listRecords as $record): ?>
<?php if (strpos($record['status'],"\tArchived\t") !== false) : ?>

How would I go about doing this same thing but in reverse? I'd like a page that included all other values that have been checked but NOT any with the value of Archived.  There are about 15 checkboxes and they can change so that's why I wanted to to an exclusion of "Archived" rather than just list all of the values I want to include. 

Any thoughts? Thank you! Tina

By csdesign - January 26, 2018

The WHERE statement worked perfectly. Thank you Leo!! 

By csdesign - January 26, 2018

Can I also use the WHERE statement to include just one value? 

Something like... 

'where' => 'status IS "%Archived%"',

By leo - January 26, 2018

Sure! You can use:

'status LIKE "%Archived%"'

Note that the "%Archived%" is a wildcard selection pattern. Which means strings like "abc123Archived" or "Archivedabc123" will also match the pattern. Normally it won't be a problem but in case if it creates confusion you may want to change it to "%\tArchived\t%".

For more information about mysql string comparison you can find them here: https://dev.mysql.com/doc/refman/5.7/en/string-comparison-functions.html


Leo - PHP Programmer (in training)

By csdesign - January 26, 2018

awesome! Thanks so much!!