Using List Section Editor FOREACH to assign variables for printed output outside of the actual FOREACH statement

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 14, 2011   (RSS)

Re: [steve99] Using List Section Editor FOREACH to assign variables for printed output outside of the actual FOREACH statement

By robin - April 13, 2011

Hey Steve,

I would recommend using arrays for this problem. It is a lot easier to deal with once it's set up. Keep the $i++ in the foreach loop, but assign the variables like this:

$dockNumber[$i] = $record['dockNumber'] //Or whatever you've named the record/column.
$personsLastName[$i] = $recocrd['personsLastName']


Then when you're ready to display, for example, dockNumber 2 you can use this:

echo $dockNumber[2];

Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Using List Section Editor FOREACH to assign variables for printed output outside of the actual FOREACH statement

By Steve99 - April 14, 2011

Great, thank you for your correspondence. It ended up being as easy as I thought it would be. I used the standard list load record output in combination with my basic foreach statement.

list($dock_assignmentsRecords, $dock_assignmentsMetaData) = getRecords(array(
'tableName' => 'dock_assignments',
));

$i = 0;
foreach ($dock_assignmentsRecords as $record) {
$title[$i] = $record['title'];
$i++;
}


Plugged in the vars where they needed to be in the docks overhead view and that was it. Simple.

P.S. I love this product! Saves me so much development time!