leading zero's
Posted: Sun Aug 16, 2009 3:45 am
Hi guys
Having trouble with leading zero's
I need to create a drop down with a loop for days of month
and i need a leading zero for first 9 days of the month i have this code, but after 01, it reverts to just 2 where it should be 02
Any Ideas?
Having trouble with leading zero's
I need to create a drop down with a loop for days of month
and i need a leading zero for first 9 days of the month i have this code, but after 01, it reverts to just 2 where it should be 02
Code: Select all
$sd="01";
if(isset($dobd)){
$dobd = $dobd;
}else{
$dobd = int(00);
}
while($sd<=31){
echo"<option value=\"";
sprintf("%02d",$sd);
echo "\"";
if($sd == $dobd){echo " selected ";}
echo ">".$sd."</option>";
$sd++;
}