need num of related record in checkboxk field

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 14, 2012   (RSS)

By Deborah - September 12, 2012

For what I need to do (shown below), I would like to know if it suggested to use the beta Lookup Related Records plugin or not. I've tried with and without the plugin and have not had success.

What I want to do...
The 'workshops' table allows the choice of multiple names from a 'presenter' checkbox list field (showing options from the 'workshop_presenters' table, using 'num' for values).

For each 'presenter' chosen for a workshop, I need to display the associated record 'num' from the 'workshop_presenters' table like this:

Mary Jones 11
Joe Smith 32
Sam Williams 44

Using the Lookup Related Records plugin I receive an error which according to an older forum post might be due to the checkboxes for the list field:
"Warning: explode() expects parameter 2 to be string..."

Without the plugin I can display a list of separated 'presenter' names, but can't bring in the associated 'num' for each from the related table.

If I know which direction (with or without plugin) is recommended I can then post my non-working code and be more specific with my questions.

Thanks in advance for any help.

Re: [Deborah] need num of related record in checkboxk field

By gregThomas - September 13, 2012

Hi Deborah,

I think you can get this data fairly easily without having to use the related records plugin. You could try doing something like this:

// load record from 'category'
list($workshopsRecords, $workshopsMetaData) = getRecords(array(
'tableName' => 'workshops',
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
$workshopRecord = @$workshopsRecords[0]; // get first record
if (!$workshopRecord) { dieWith404("Record not found!"); } // show error message if no record found

$listOfPresenters = array_combine($workshopRecord['workshop_presenters:values'],$workshopRecord['workshop_presenters:labels']);

foreach($listOfPresenters as $key => $item){
echo $item." ".$key;


Although you might have to do a slightly more complex query if your looking to get more data on each presenter than this. But even then I think it would be simpler to write the code to do it than to use the related records plugin.

Greg Thomas

PHP Programmer -