Multi Record listings on one page - need help

6 posts by 2 authors in: Forums > CMS Builder
Last Post: June 19, 2012   (RSS)

By sublmnl - June 12, 2012

Hi guys, for some reason this one is escaping me.
I know how to filter list records by a 'where' in the php header but not on the echo call within the html

I have one multirecord section that has three select options for an entry: globally, locally and neighborhood.
When a record is saved, one of those options has to be selected.

I need to display these records on one page separated into three groups and this has me going in circles.

The select options are called "Serving Type?" which are stored in another multirecord section and brought in via 'get options from database'.

I have done this before but filtered by the options to pull in one group of items on a page but not to filter all items by groups on one page.

Little help here would be appreciated.
Thanks.

Re: [sublmnl] Multi Record listings on one page - need help

By Jason - June 12, 2012 - edited: June 19, 2012

Hi,

So you have a section with a field called serving_type that has a value of either globally, locally, or neighborhood. Is that right?

If so, what you can do is go through your list and divide your record set into 3 separate record sets based on this value.

For example:

<?php
$globallyRecords = array();
$locallyRecords = array();
$neighborhoodRecords = array();

foreach ($myRecordSet as $record) {

if ($record['serving_type'] == "globally") {
$globallyRecords[] = $record;
}
elseif ($record['serving_type'] == "locally") {
$locallyRecords[] = $record;
}
elseif ($record['serving_type'] == "neighborhood") {
$neighborhoodRecords[] = $record;

}

}
?>


Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Multi Record listings on one page - need help

By sublmnl - June 13, 2012

Hmnn didn't work.

Notice: Undefined variable: myRecordSet in ......[server pathway to page and line number]
Warning: Invalid argument supplied for foreach() in ...... [server pathway to page and line number]


I put the code on the page, uploaded and gave me that.

Re: [sublmnl] Multi Record listings on one page - need help

By Jason - June 14, 2012

Hi,

The code I provided used example variables, since I didn't know how you named things on your page. In that code, you'll need to replace $myRecordSet with the name of the record set returned by getRecords().

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [sublmnl] Multi Record listings on one page - need help

By Jason - June 19, 2012

Hi,

You're right. I fixed the typo in the post. There is still probably some syntax error on your page. Could you attach the .php file you're working with so we can take a look?

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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