Displaying multiple records that have same list field value

3 posts by 3 authors in: Forums > CMS Builder
Last Post: April 20, 2010   (RSS)

By depdesign - April 20, 2010

I'm trying to find a way where I can display records from a section by the value from a pulldown list created in the CMS.

For example, below is a sample dropdown list field (Field Name: entertainment) in the CMS for a section titled "media".

Music|Compact Disc
Music|Radio
Music|Ipod
News|Newspaper
News|Televison

I want to display records on a page that have the value of Music to appear on a page.

Below is the code I tried:
list($mediaRecords, $mediaMetaData) = getRecords(array(
'tableName' => 'media',
'where' => "entertainment = \"Music\"",
));

This does not display anything.

If I do this....

list($mediaRecords, $mediaMetaData) = getRecords(array(
'tableName' => 'media',
'where' => "entertainment = \"Compact Disc\"",
));


It only displays the one record that has Compact Deisc selected in the list.
Dan Perez

Re: [depdesign] Displaying multiple records that have same list field value

Hi depDesign,

I found this and it might help.

To show only record from a specific region you can use a MySQL Where query like this: region = "north west"

You can either enter that in the code generator (at the bottom under "Filter Results") or in the viewer code like this:

Code

list($records, $recordMetaData) = getRecords(array(
'tableName' => 'bios',
'perPage' => 5,
'where' => 'region = "north west"',
));


The perPage code is optional of course.

Hope it works.

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php