Hello ... I'm trying to output a simple list of categories but am having a bit of trouble. I've followed Chris's sub-category tutorial (http://www.interactivetools.com/forum/gforum.cgi?post=77230) successfully for other outputs, but can't get this to work.
I have a list of businesses and individuals that fall into one of 9 categories. My desired output is as follows:
Category 1
- business 1
- business 2
- business 3
Category 2
- business 4
- business 5
- business 6
Category 3
- business 7
- business 8
- business 9
- business 10
etc.
But when I output my list each member appears in every category, as in:
Category 1
- business 1
- business 2
- business 3
Category 2
- business 1
- business 2
- business 3
etc.
I know this is a simple coding issue. Here is what I have in my file:
HEAD
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/tucg/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
list($categoriesRecords, $selectedCategory) = getCategories(array(
'tableName' => 'categories',
'categoryFormat' => 'onelevel',
));
list($participantsRecords, $participantsMetaData) = getRecords(array(
'tableName' => 'participants',
));
BODY
<?php foreach ($categoriesRecords as $categoryRecord): ?>
<h2><?php echo $categoryRecord['name'] ?></h2>
<ul>
<?php if ($categoryRecord['num']): ?>
<?php foreach ($participantsRecords as $record): ?>
<li><?php if ($record['url']): ?><a href='http://<?php endif ?>
<?php echo $record['url'] ?><?php if ($record['url']): ?>' target='_blank'><?php endif ?><?php echo $record['title'] ?>
<?php if ($record['url']): ?></a><?php endif ?>
<span class="contact-info"><?php echo $record['phone_number'] ?></li>
<?php endforeach ?>
<?php endif ?>
</ul>
<?php endforeach ?>
</ul>
Any help would be appreciated.
Many thanks,
Chris P