Re: [csdesign] How to setup defaults for fields in multiple locations
Hi Tina,
Here's an example to help get you started.
In this example code, I've had to make a number of assumptions. First, that the name of your check box list fields are open_trails, and groomed_overnight. I've also assumed that the values of your list are the text fully spelled out (ie, "Homebound Traverse").
The first thing we do is to set up an array with the text we want to be able to display. Then we take our list fields and turn them into arrays we can use:
<?php
$openTrailText = array( 0 => 'CLOSED', 1 => 'OPEN');
$groomedText = array( 0 => 'NO', 1 => 'YES' );
$open_trails = explode( '\t', trim($mountain_statsRecord['open_trails'], '\t'));
$groomed_overnight = explode( '\t', trim($mountain_statsRecord['groomed_overnight'], '\t'));
?>
After that we output out text based on whether or not a name is in our array. Here's an example for Homebound Traverse"
<tr>
<td align="left" valign="top"><img src="images/trail-easy.png" alt="easy trail" width="23" height="18" align="absbottom" />Homebound Traverse</td>
<td align="center" valign="top" class="tableInfo"><?php echo $openTrailText[ in_array('Homebound Traverse',$open_trails)];?></td>
<td align="center" valign="top" class="tableInfo"><?php echo $groomedText[ in_array('Homebound Traverse',$groomed_overnight)];?></td>
</tr>
Please note that this code is untested and may need to be modified depending on how your data is being stored.
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/