Product list by tick box

3 posts by 2 authors in: Forums > CMS Builder
Last Post: February 1, 2014   (RSS)

By crystal - January 30, 2014

HI, can you help?

from a list of products i am trying to only list the products that have a tick against a certain field

ie i have a checkboxes (multi value) list

with bakery, chocolate, supermarket  ect...

the code below works if i only have a single item list

can i make it work for a multi item list

Code:-

  <?php foreach ($testRecords as $record): ?>
  <?php if ($record['retail'] != "supermarket") { continue; } ?>
 
      Record Number: <?php echo htmlencode($record['num']) ?><br/>
      Title: <?php echo htmlencode($record['title']) ?><br/>
      Content: <?php echo $record['content']; ?><br/>
      
     

      _link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>
      <hr/>
    <?php endforeach ?>

    <?php if (!$testRecords): ?>
      No records were found!<br/><br/>
    <?php endif ?>

CT

By crystal - February 1, 2014

Hi Greg

Thanks for the reply and lesson

I managed to get around it by the following:- 

// load records from 'test'
list($testRecords, $testMetaData) = getRecords(array(
'tableName' => 'test',
'where' => "retail LIKE '%\tsupermarket\t%' ",
'loadUploads' => true,
'allowSearch' => false,
));

(found this on your forum - many thanks)

Chris

CT