////Number of options to show $opts = 12;
////Array of months $m = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
////Get starting year and month $sm = date('n', strtotime("-3 Months")); $sy = date('Y', strtotime("-3 Months"));
////Create select menu echo "<select name='test'>\n";
for($i=0;$i<$opts;$i++) {
////Check for current month and year so we can select it
if($m[$sm - 1] == date('M') && $sy == date('Y')) {
echo "<option value='".$m[$sm - 1]." ".$sy."' selected='selected'>".$m[$sm - 1]." ".$sy."</option>\n";
} else {
echo "<option value='".$m[$sm - 1]." ".$sy."'>".$m[$sm - 1]." ".$sy."</option>\n";
}
//// Fix counts when we span years
if($sm == 12) {
$sm = 1;
$sy++;
} else {
$sm++;
}
}
echo "</select>\n";
////Array of months $m = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
////Get starting year and month $sm = date('n', strtotime("-3 Months")); $sy = date('Y', strtotime("-3 Months"));
////Create select menu echo "<select name='test'>\n";
for($i=0;$i<$opts;$i++) {
////Check for current month and year so we can select it
if($m[$sm - 1] == date('M') && $sy == date('Y')) {
echo "<option value='".$m[$sm - 1]." ".$sy."' selected='selected'>".$m[$sm - 1]." ".$sy."</option>\n";
} else {
echo "<option value='".$m[$sm - 1]." ".$sy."'>".$m[$sm - 1]." ".$sy."</option>\n";
}
//// Fix counts when we span years
if($sm == 12) {
$sm = 1;
$sy++;
} else {
$sm++;
}
}
echo "</select>\n";
0 comments:
Post a Comment