Multi Record listings on one page - need help

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

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: [Jason] Multi Record listings on one page - need help

By sublmnl - June 18, 2012

mnnnmnnnn

Still no dice.
This is my code way up top:

// load records
list($serving_listRecords, $serving_listMetaData) = getRecords(array(
'tableName' => 'serving_list',
'allowSearch' => '0',

));


I replaced your $myRecordset with $serving_listRecords
and it didn't even show. Not even a page error.
Also I think you had a small typeo on the previous post calling 'globally' twice. So I changed that to neighborhood and still no show.

Still need a little help. Thx.

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/