Hey all,
Have a logical problem on my hands here. Please let me know if you have any ideas.
I want to map a list of "zones" and "activity groups" and display a checked checkbox if already assigned in the database and an unchecked box if not assigned. The only problem is that it is displaying another set of checkboxes after the first set. Below is the code. if you find funny looking function such as form_tag and checkbox_tag, just know that I am working through a framework. Thanks all. Any help is greatly appreciated.
Have a logical problem on my hands here. Please let me know if you have any ideas.
I want to map a list of "zones" and "activity groups" and display a checked checkbox if already assigned in the database and an unchecked box if not assigned. The only problem is that it is displaying another set of checkboxes after the first set. Below is the code. if you find funny looking function such as form_tag and checkbox_tag, just know that I am working through a framework. Thanks all. Any help is greatly appreciated.
Code:
<?php
// get count for the activity group in order to get the colspan for header
$numActGroup = count($allActGroup);
?>
<?php echo form_tag('property'); ?>
<div id='vrs_actionbar'>
<?php echo submit_tag('Submit'); ?>
</div>
<div class='vrs_grid' style='width:800px'>
<table border=0 class='vrs_datagrid'>
<tr><th></th><th colspan=<?php echo $numActGroup?>><center>Zone Mappings</center></th></tr>
<tr><th></th>
<?php foreach($allActGroup as $actGroup)
{?>
<th><?php echo $actGroup->getDescription() . '{' . $actGroup->getActgroupUnid() . '}'; ?></th>
<?php } ?>
</tr>
<?php
foreach($mapZones as $mapZone){
$mZoneID[] = $mapZone->getZoneUnid();
$mActGroupID[] = $mapZone->getActgroupUnid();
}
// dump the contents of both of the array
vrsTools::VRSPrintr($mZoneID, 'mZoneID');
vrsTools::VRSPrintr($mActGroupID, 'mActGroupID');
?>
<?php echo 'mZoneID: ' . count($mZoneID) . '<BR>'; ?>
<?php echo 'allActGroup: ' . count($allActGroup) . '<BR>'; ?>
<?php foreach($allZones as $zone)
{?>
<tr <?php echo altrow(); ?>><th><?php echo 'Zone ' . $zone->getName() . '{' . $zone->getZoneUnid() . '}'; ?></th>
<?php foreach($allActGroup as $actGroup){ ?>
<?php // ASSUMPTION: The number of elements in $mzoneID and $mActGroupID are the same ?>
<?php
for($i = 0; $i < count($mZoneID); $i++) {
if(($zone->getZoneUnid() == $mZoneID[$i]) && ($actGroup->getActgroupUnid() == $mActGroupID[$i]))
{ ?>
<td>
<?php echo 'getZoneUnid:' . $zone->getZoneUnid() . checkbox_tag('check[]', '1', true) . 'getActgroupUnid:' . $actGroup->getActgroupUnid();?>
</td>
<?php }
else
{ ?>
<td>
<?php echo checkbox_tag('check[]', '1', false); ?>
</td>
<?php
}
// echo 'i: '. $i . '<BR>';
}
// break;
?>
<?php } ?>
</tr>
<?php } ?>
</table>
</form>
</div>