My php program cannot display result correctly. After run array_push($y_options,$tmp_yr), $y_options doesn't show 2005, 2006, 2007, 2008, 2009. $y_options only show 2009, 2009, 2009, 2009, 2009.
Same for $m_options. It only show December rather than January to December.
My source code is as follow:
Code: Select all
$array_month = array("1"=>"January","2"=>"Febuary","3"=>"March","4"=>"April","5"=>"May","6"=>"June","7" =>"July","8"=>"August","9"=>"September","10"=>"October","11"=>"November","12"=>"December");
$array_year = array("2005","2006","2007","2008","2009");
$m_options = array();
while (list($indx,$mth) = each ($array_month)) {
$tmp_mth->m_title = $mth;
$tmp_mth->m_value = "?month=".$indx."&year=".$year;
if ($indx == $month) {
$tmp_mth->selected = "selected";
}
array_push($m_options,$tmp_mth);
$tmp_mth->selected = "";
}
$y_options = array();
foreach ($array_year as $yr) {
$tmp_yr->y_title = $yr;
$tmp_yr->y_value = "?month=".$month."&year=".$yr;
if ($yr == $year) {
$tmp_yr->selected = "selected";
}
array_push($y_options,$tmp_yr);
$tmp_yr->selected = "";
print_r ($tmp_yr->y_title);
print_r ($y_options);
}When you click drop down menu Month and Year, it always show December and 2009. The correct result of drop down menu should be January to December, 2005 to 2009.
I am not sure where is the possible problem. Would appreciate if anybody can help.
Regards,
Grace