Filter records from a variable - related articles

2 posts by 2 authors in: Forums > CMS Builder
Last Post: September 18, 2014   (RSS)

Hey there

Best thing to do is use some SQL trickery to get four random records.

So you've got $paquetes_lunamielerosRecord, which contains the category you want to get four related records from. I'm not sure how your schema is set up, but here's how I'd get those four records:

// load records from 'paquetes_lunamieleros'
  list($paquetes_lunamielerosALLRecords, $paquetes_lunamielerosALLMetaData) = getRecords(array(
    'tableName'   => 'paquetes_lunamieleros',
    'loadUploads' => true,
    'allowSearch' => true,
    'where'       => 'category = '.$paquetes_lunamielerosRecord['category'],
    'limit'       => '4',
    'orderBy'     => 'RAND()'
  ));

The RAND() option should choose four random records from the right category.

Does this help?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/