我试图将选定的属性赋予存储在 SESSION 中的年份(在我发布的脚本中,日期 1990-06-27 是我正在谈论的 SESSION )。$month 一切顺利,但是当我对 $year 执行相同的 If 语句时,它不起作用,我真的不知道为什么。
list($y,$m,$d)=explode('-', "1990-06-27");
for($month=1; $month<=12; $month++) {
$monthName = date("F", mktime(0, 0, 0, $month));
$month = date("m", mktime(0, 0, 0, $month));
$luni = array ('January' => 'Ianuarie', 'February' => 'Februarie', 'March' => 'Martie', 'April' => 'Aprilie', 'May' => 'Mai', 'June' => 'Iunie', 'July' => 'Iulie', 'August' => 'August', 'September' => 'Septembrie', 'October' => 'Octombrie', 'November' => 'Noiembrie', 'December' => 'Decembrie');
If($m === $month) {
$selected = 'selected="selected"';
$monthOptions .= "<option value=\"{$month}\" $selected>{$luni[$monthName]}</option>\n";
} else {
$monthOptions .= "<option value=\"{$month}\">{$luni[$monthName]}</option>\n";
}
}
$an_curent = date("Y", time());
for($year = $an_curent - 80; $year <= $an_curent - 16; $year++) {
If($y === $year) {
$selected = 'selected="selected"';
$yearOptions .= "<option value=\"{$year}\" $selected>{$year}</option>\n";
} else {
$yearOptions .= "<option value=\"{$year}\">{$year}</option>\n";
}
}