EXCLUDING A VALUE From a Checklist

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

By leo - January 26, 2018

Hi Tina,

If you don't need a full list of records for the page, I would recommend adding where statements when you get records from the database. In the beginning of your php script there should be something like this:

list($stallion_listRecords, $stallion_listMetaData) = getRecords(
  'tableName' => ...,
  ...
);

Add the where statement like this:

list($stallion_listRecords, $stallion_listMetaData) = getRecords(
  'tableName' => ...,
  'where' => 'status NOT LIKE "%Archived%"',
  ...
);

That should give you all the records that don't have an Archived status. Or you can just replace the exclamation mark with an equal sign like this:

if (strpos($record['status'],"\tArchived\t") === false)

Let me know if you have any questions!

Thanks,

Leo - PHP Programmer (in training)
interactivetools.com

The WHERE statement worked perfectly. Thank you Leo!! 

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

Thanks!

Leo - PHP Programmer (in training)
interactivetools.com

awesome! Thanks so much!!