Or you could simply set the variables in the forms to what you recieved in your POST Arguments, in your case of drop down boxes that would be setting the selected attribute in the right place,
$month = isset($_REQUEST['month']) ? $_REQUEST['month'] : '';
if ($key == $month){
$select .= " selected>".$val."\n";
}// end if
So this is what i did to retain the values of the month
but why is it after i sent the form the value minus 1.
that is to say.. i sent 12 the value displayed is 11
$month = array (1=>"-","01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
$select = "<select name=\"month1\">\n";
foreach ($month as $key => $val) {
$select .= "\t<option val=\"".$key."\"";
$month = isset($_REQUEST['month']) ? $_REQUEST['month'] : '';
if ($key == $month){
$select .= " selected>".$val."\n";
}// end if
else{
$select .= ">".$val."\n";
}// end else
}// end foreach
$select .= "</select>";
echo $select;
As for my year, how should it be done?
// Displaying the Year in the DateOfOccurence drop down box
$year = date("Y"); //get the current year from the system
echo "<select name='year'>\n";
echo '<option value="" selected">-</option>';
for ($n=$year;$year-10<=$n;$n--) { // gets the current year and do a subtraction of 10 to display the array of descending 10 years
echo " <option value=\"$n\">$n</option>";
} // end for
echo "</select>\n";
}// end function