nearly have it...but need a wee bit of assistance. attempting to single out selected results from a details page in one section, of selected fields from another section

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

Hi Codee, 

Let's try adding a where to your cases query at the top (and removing the 'joinTable'), try this: 

// get cases for this lesson
$caseNums      = $lessonsRecord['case_examples:values'] ?? [];  // array of case nums (default to empty array)
$caseNums      = array_map('intval', $caseNums);                // ensure nums are integers
$caseNumsAsCSV = implode(",", $caseNums);                       // convert to CSV string, e.g., 1,2,3
$caseNumsAsCSV = $caseNumsAsCSV ?: '0';                         // default to '0' if empty
$casesWHERE    = "num IN ($caseNumsAsCSV)";                     // build WHERE clause for SQL query

// load records from 'cases'
list($casesRecords, $casesMetaData) = getRecords(array(
    'tableName'   => 'cases',
    'loadUploads' => true,
    'allowSearch' => true,
    'where'       => $casesWHERE,
));

Let me know if that works for you.

Dave Edis - Senior Developer
interactivetools.com

Mr. Dave,

Perfect! THANK you very much!