I have a list of distributors populating from a list of states.
list($statesRecords, $statesMetaData) = getRecords(array(
'tableName' => 'states',
'loadUploads' => false,
'allowSearch' => false,
));
-------------------------------------------------------------
<?php foreach ($statesRecords as $key=>$record): ?>
<div class="panel-group secundary" id="accordion2">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapse2<?php echo $key;?>"><?php echo htmlencode($record['title']) ?></a>
</h4>
</div>
<div id="collapse2<?php echo $key;?>" class="accordion-body collapse">
<? // load records from 'distributors'
list($distributorsRecords, $distributorsMetaData) = getRecords(array(
'tableName' => 'distributors',
'loadUploads' => false,
'allowSearch' => false,
'where' => "states = '". $record['num'] . "'",
));
?>
<?php foreach ($distributorsRecords as $distributor): ?>
<div class="panel-body">
<strong><?php echo htmlencode($distributor['title']) ?></strong><br/>
<p><?php echo htmlencode($distributor['address']) ?><br/>
<?php echo htmlencode($distributor['phone']) ?><br/>
Contact: <?php echo htmlencode($distributor['contact_name']) ?>
</p>
<hr>
</div>
<?php endforeach ?>
</div>
</div>
</div>
<?php endforeach ?>
Can I write it somehow to list ONLY the states that actually have a distributor. Please Note: I built this as a list of states that are associated in a list of distributors. Maybe I need to move that get records to the outside of the loop?
Let me know what you think.
Michael Moyers
Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.
"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"