Re: Outputting a 2 digit number < 10
| From: | Pavel Jartsev | Date: | Thu, 25 Jan 2001 17:31:54 +0000 |
| Subject: | Re: Outputting a 2 digit number < 10 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-36664@lists.php.net to get a copy of this message | ||
Jamie wrote:
>
> ...
>
> <? 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>"
> ?>
>
> ...
Maybe this for-cycle is doing what u want
(if i didn't misunderstood your question).
<?
for ($i=1; $i<$daysinmonth+1; $i++){
$i2 = sprintf( "%02d", $i );
echo "<option value=\"".$i2."\"".( $i2 == $day ? '
selected' : ''
).">$i2\n";
}
?>
Hope this helps.
--
Pavel a.k.a. Papi