[eluser]vincej[/eluser]
Hi - I have a drop down menu which dynamically presents dates. See code below.
Code:
echo form_open('admin/reports/SpecificLocationDate');
foreach ($deliverydates as $series => $data) {
$TheDates = explode(',', $data['TheDates']);
}
$options = array(
$TheDates['0']=>strftime("%a %d %b %Y", $TheDates['0']),
$TheDates['1']=>strftime("%a %d %b %Y", $TheDates['1']),
$TheDates['2']=>strftime("%a %d %b %Y", $TheDates['2']),
$TheDates['3']=>strftime("%a %d %b %Y", $TheDates['3'])
);
echo "Filter by Delivery Date: ";
echo form_dropdown('locations',$options,'all');
echo form_hidden('locationid',$data['locationid']);
echo " ".form_submit('submit','Submit')."</span><br><br><br>";
echo form_close();
OK - The user can select a delivery date to filter the future orders. It all works excellently so long as the dates
are in the future. If the user is a bit slow in maintaining the delivery dates and accidentally allows one of them to slip into the past, then the query that fills the drop down with future dates, causes one or more of the drop down options being empty. This causes a nasty "Undefined index:" error. What is more strftime() reacts to the empty index by filling it in with Dec 31 1969.
So, I need advice on how I can manage this situation when the user lets a date go into history. I had thought of perhaps using a switch statement to provide multiple different sets of drop down options. But that feels very messy. Of course I cou;d just change the initial query to allow historical dates to be presented - but that feels amaturish.
Any Advice is gratefully received,
MANY THANKS !