dc_jt Posted June 7, 2007 Share Posted June 7, 2007 Hi I have the following drop down which is to display 1-12 for months January to December. (It also contains -- which means no month selected.) However, the months are displayed 1,2,3, 4 etc. How can I get it to be displayed like 01,02,03,04 etc?? I tried using printf but not sure whether Ive put it in the right place?? Thanks <select name="Endsdatem" class="fmgreynormal"> <? if ($_GET['iPhaseId'] && formatDate($oIndivualPhase->end_date) != '00/00/0000') { for ($i=1;$i<=12;$i++) {?><? echo "<option value=\"$i\""; if ($i == $EndaMonth) echo " selected"; echo ">".printf(">%02d</option>",$i); } ?> <option value="00">--</option> <?php } else { for ($i=1;$i<=12;$i++) { echo "<option value=\"$i\">$i</option>"; } echo "<option value=\"--\" selected>--</option>"; } ?> </select> Link to comment https://forums.phpfreaks.com/topic/54562-solved-adding-a-0-before-1234-etc-in-month-drop-down/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.