
October 8th, 2004, 06:37 PM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 6
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Trouble with a date select box
I have this date select box (for months only )
PHP Code:
echo "<form action=\"index.php\" method=\"GET\">\n";
echo "<table border=\"1\">\n";
echo "<th colspan=\"2\">View Other Months</th>\n";
echo "<tr>\n";
echo "<td>\n";
echo "<select name=\"months\">\n";
foreach ($months as $key => $val ) {
($key == date('m', time())) ? ($sel = " selected") : ($sel = "");
echo "<option value=\"".$key."\"$sel>".$val."</option>\n";
}
When i select a month earlier than the current month ( october so fa ), there is 10 added to the month. January become 11, February becomes 12 and so on.
I have tried to change it here:
PHP Code:
echo "<form action=\"index.php\" method=\"GET\">\n";
echo "<table border=\"1\">\n";
echo "<th colspan=\"2\">View Other Months</th>\n";
echo "<tr>\n";
echo "<td>\n";
echo "<select name=\"months\">\n";
foreach ($months as $key => $val ) {
($key == date('m', time()-10)) ? ($sel = " selected") : ($sel = "");
echo "<option value=\"".$key."\"$sel>".$val."</option>\n";
}
But i haven't solved it yet.
Any ideas??
|