Hi Jac,
So you want to get the items in the year drop down dynamically from the section? I would do something like this:
//Set the year data to nothing
$yearData = "";
//This array will contain all of the years used.
$yearList = array();
//This will get all the entries from the year table
$years = mysql_select('year');
//loop through the year table entries
foreach($years as $year){
//If the year isn't stored in the year list, add it!
if(!in_array($year['year'], $yearList)){
$yearList[] = $year['year'];
}
}
if(@$_REQUEST['getYear']){
//Validate the year post data
$year = intval($_REQUEST['year']);
//Get the record for this year.
$yearData = mysql_get('year', null, "year = '$year'");
}
?>
<form method="post" action="scratch.php">
<input type="hidden" name="getYear" value="go" />
<!-- year drop down. -->
<select name="year" >
<!-- loop through the year entries -->
<?php foreach($yearList as $yearEntry): ?>
<option value="<?php echo $yearEntry; ?>" ><?php echo $yearEntry; ?></option>
<?php endforeach; ?>
</select>
<input type="submit" name="send" value="Go!" />
</form>
<!-- If the year data is returned, display it below -->
<?php if($yearData): ?>
<div id="yearBox">
<!-- you will need to change the the variables to match the field names you have used -->
<span class="title">January</span><span><?php echo $yearData['start_jan']; ?></span><span><?php echo $yearData['finish_jan']; ?></span><br>
<span class="title">Febuary</span><span><?php echo $yearData['start_feb']; ?></span><span><?php echo $yearData['finish_feb']; ?></span><br>
<span class="title">March</span> <span><?php echo $yearData['start_march']; ?></span><span><?php echo $yearData['finish_march']; ?></span><br>
<span class="title">April</span> <span><?php echo $yearData['start_apr']; ?></span><span><?php echo $yearData['finish_apr']; ?></span><br>
<span class="title">May</span> <span><?php echo $yearData['start_may']; ?></span><span><?php echo $yearData['finish_may']; ?></span><br>
</div>
<?php endif; ?>
This is just an example, so you'll need to change some of the variables to match one's you have used.
Thanks!
Greg
Greg Thomas
PHP Programmer - interactivetools.com