[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:
PHP Code:
<?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> </td>
<td><select name="location" size=1>
<option value=GA>Georgia</option></select></td></tr>
This is the portion of the script which displays the date:
PHP Code:
<tr><td><b>Planned Closing Date:</b></td><td> </td><td><?php echo $_SESSION [ 'month' ] . $_SESSION [ 'day' ] . $_SESSION [ 'year' ]; ?> </td></tr>
Can someone help me out?
Thanks.
PHP Code:
<?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> </td><td><?php echo $date ; ?> </td></tr>
Thank you, that worked perfectly.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks