I'm very new to php and I'm simply trying to modify some existing code to display the years 2008 and 2009 instead of 2009 and 2010. I want to use varibales so I don't have to update it every year.
The code is currently
<?php
for($x=$curYear;$x<=$curYear+1;$x++) {
echo "<option value=\"".$x."\"";
if($curYear==$x) { echo "selected"; }
echo ">".$x."</option>\n";
}
?>
This shows this year + 1 as my options. I thought I could just change "$curYear+1" to "$curYear-1" and it would show 2009 and 2008, but I keep getting errors. Is this as simple as I'd expect. What should I do? Any help would be appreciated.
Adding year options to a drop down
Moderator: General Moderators
Re: Adding year options to a drop down
What do you set the $curYear to?
Take a look at getdate() PHP function.
Take a look at getdate() PHP function.
There are 10 types of people in this world, those who understand binary and those who don't
Re: Adding year options to a drop down
I don't see a getDate, but this is the line I think it is using:
$curYear=date("Y");
$curYear=date("Y");