/    Sign up×
Community /Pin to ProfileBookmark

Year not working

Hi all. Once again, I am practicing php. The lesson I’m working on lets the visitor select the date. Once I finished writing the script, the month and day are working perfectly. The year however, is showing as 1 – 10, instead of 2000 – 2010.

The script for the year is”

[COLOR=red]// Create the year pull-down menu.
$EndYear = $Year + 10;

while ($Year <= $EndYear ) {
print(“<option value=$Year>$Year</option>n”);
$Year++;
}

print (“</select>n”);
print (“<p><input type=submit name=submit value=”Go!”></form>n”);

[/COLOR].

You can see what I mean for yourself at [url]http://iwdtestsite.com/ControlStructures/select.php[/url] .

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@solavarJun 19.2004 — How are you generating $Year?

If $Year is this year then you've to say...
[code=php]
<?php
$Year = date("Y", mktime());
?>
[/code]
×

Success!

Help @Magikey spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...