Outputting a 2 digit number < 10

From: Date: Thu, 25 Jan 2001 17:07:38 +0000
Subject: Outputting a 2 digit number < 10
Groups: php.general 
Request: Send a blank email to php-general+get-36654@lists.php.net to get a copy of this message
I need to enable a user to insert an 'NEWS' item into a mySQL table one of the definable limits for the user is to be the date that the news is to be displayed. Currently the collum is in a 'date' format and should be stored in a YYYYMMDD - being Australian we are used to the exact reverse of that so I though it best to produce a series of three select options in html and then joing the values before inserting them $form_date = $form_date_Year . $form_date_month . $form_date_day; CRUX: the looping format I'm using to make the options needs to output a 2 digit number as a single digit like 1 as compared to 01 will invalidate the date Sample of a loop I use to output an option <? echo"<select name=\"form_date_day\">"; $day = (date ("d")); $daysinmonth = (date("t")); for ($i=00;$i<$daysinmonth;$i++){ if ($i == $day) { echo("<option SELECTED value=\"$i\">$i</option>\n"); } else { echo("<option value=\"$i\">$i</option>\n"); } } echo"</select>" ?> Any help will be apreciated Jamie

« previous php.general (#36654) next »