Re: Date in a dropbox box

From: Date: Tue, 11 Mar 2003 01:45:30 +0000
Subject: Re: Date in a dropbox box
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-26243@lists.php.net to get a copy of this message
Hi there, Thank you John, you are a lifesaver :-) Chris > > I have a form which displays 3 dropdowns, day, month and year, I have > it > > displaying the default of the dropdown for month no problem, but how > can I > > get it to select the current date (day) in the dropdown, but show 31 > days > > nomatter how many days are in the month? This is important even > though it > > sounds odd :-) > > > > so if it was the 5th of a month, it would show 5 as a default value, > but > > allow you to select 1-4 before that and 6-31 after it. > > Lots of ways you can do it. > > $today = date('d'); > for($x=1;$x<=31;$x++) > { > echo '<option value="$x"' . (($x==$today)?' > selected':'') . > '>$x</option>'; > } > > ---John W. Holmes... > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > today. http://www.phparch.com/ > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.db (#26243) next »