/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Drop Down Box Help

Hello:

I have a script which contains a drop down boxes for month, day, year and location.

When the person clicks submit another script processes the form. In this script, I would like to show the name of the month not the numeric value of the month. When I display the date, I get 112007. I would like to show ‘January” rather than “1” and I would like the date to display as January 1, 2007.

My question is how do I use the label from the drop down box for month so the name of the month appears? Also, how do I format this date?

Here is how the drop down boxes appear:

[code=php]
<?php
$months = array (1 => ‘January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’,
‘September’, ‘October’, ‘November’, ‘December’);

//Make the days and years arrays

$days = range (1,31);
$years = range (2007, 2015);

//Make the months pull-down menu

echo ‘<select name=”month”>’;
foreach ($months as $key => $value) {
echo “<option value=”$key”>$value</option>n”;
}
echo ‘</select>’;

//Make the days pull-down menu

echo ‘<select name=”day”>’;
for ($day = 1; $day <= 31; $day++) {
echo “<option value=”$day”>$day</option>n”;
}
echo ‘</select>’;

//Make the years pull down menu

echo ‘<select name=”year”>’;
$year = 2007;
while ($year <= 2015) {
echo “<option value=”$year”>$year</option>n”;
$year++;
}
echo ‘</select>’;

?>
</td></tr>
<tr><td><b>Property Location:</b></td><td>&nbsp;</td>
<td><select name=”location” size=1>
<option value=GA>Georgia</option></select></td></tr>
[/code]

This is the portion of the script which displays the date:

[code=php]
<tr><td><b>Planned Closing Date:</b></td><td>&nbsp;&nbsp;</td><td><?php echo $_SESSION[‘month’] . $_SESSION[‘day’] . $_SESSION[‘year’]; ?></td></tr>
[/code]

Can someone help me out?
Thanks.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@MrCoderMar 16.2007 — [code=php]
<?php
$date = date("F j, Y", mktime(0, 0, 0, $_SESSION['month'], $_SESSION['day'], $_SESSION['year']));
?>
<tr><td><b>Planned Closing Date:</b></td><td>&nbsp;&nbsp;</td><td><?php echo $date; ?></td></tr>
[/code]
Copy linkTweet thisAlerts:
@focus310authorMar 16.2007 — Thank you, that worked perfectly.
Copy linkTweet thisAlerts:
@MrCoderMar 16.2007 — Glad I could help!
×

Success!

Help @focus310 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.3,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...