Display like records from a multi-select from another multi-record

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

By JeremyHarrison - October 6, 2014

Hi Everyone,

I am building a website for a client where they have a list of locations contained in a multi-record and they then have staff profiles (also a multi-record) which includes which location the person works at. The locations within the staff profiles are listed via "Get options from database" with Value:Num and Label:Title.

On the location pages I want to display which staff work at that location. I've had no problem listing which locations the staff work at on their individual profile pages, but this new setup is causing some issues.

An example of the current location page can be viewed at http://www.thedentalproject.com.au/locations/birkdale-dentist/

I've taken the same approach I've used for blog categories to display content where multiple values may have been selected but that is just resulting in only displaying staff members working at both locations.

This is what I'm loading in terms of records:

   // load record from 'locations'
  list($locationsRecords, $locationsMetaData) = getRecords(array(
    'tableName'   => 'locations',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $locationsRecord = @$locationsRecords[0]; // get first record
  
   // load records from 'our_people'
   $where = "location LIKE '%\t" . mysql_escape($locationsRecord['num']) . "\t%'";
  list($our_peopleRecords, $our_peopleMetaData) = getRecords(array(
    'tableName'   => 'our_people',
    'loadUploads' => true,
    'allowSearch' => false,
'where'       => $where,
  ));

I'm then just displaying with a simple "foreach" call with the idea that only the appropriate records will be listed based on the criteria established above. Obviously, this has failed terrible.

If you can provide any help it would be greatly appreciated.

Kind regards,
Jeremy.