Add characters to month loop?
Posted
by JM4
on Stack Overflow
See other posts from Stack Overflow
or by JM4
Published on 2010-05-21T01:01:11Z
Indexed on
2010/05/21
1:10 UTC
Read the original article
Hit count: 319
I currently have a php loop running exactly how I need it with proper validations (in both php and javascript) with one exception, if the month is less than 2 digits, (i.e. 1,2,3,4), I need for a '0' to appear before:
01 - January 02 - February ... 10 - October
My code for the loop is currently:
<select name="Month">
<option value="">Month</option>
<?php
for ($i=1; $i<=12; $i++)
{
echo "<option value='$i'";
if ($fields["Month"] == $i)
echo " selected";
echo ">$i</option>";
}
?>
</select>
any ideas?
Also note, this month date is being stored in session, not interested in printing to screen
© Stack Overflow or respective owner