Hi,
Friday, October 1, 2004, 6:16:46 AM, you wrote:
aan> Hi,
aan> to create a list of all months in drop-down menu I use this code:
aan> <?php
aan> $month_names = array(1=>'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
aan> 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
?>>
aan> <select name="QuoteMonth">
aan> <option value=""></option>
aan> <?php
aan> for($i=1; $i<=12; $i++)
aan> {
aan> if(date('m') == $i) $selected_QuoteMonth = 'SELECTED';
aan> else $selected_QuoteMonth = '';
aan> echo "<option value=$i $selected_QuoteMonth> $i </option>";
aan> }
?>>
aan> </select>
aan> Is there any better way?
aan> Thanks for any help.
aan> Afan
Another way to skin this cat :
$month_names = array(
'Jan'=>'', 'Feb'=>'', 'Mar'=>'','Apr'=>'',
'May'=>'', 'Jun'=>'', 'Jul'=>'','Aug'=>'',
'Sep'=>'', 'Oct'=>'', 'Nov'=>'', 'Dec'=>'');
$month_names[date('M')] = ' selected';
echo '<select name="month">';
foreach($month_names as $month=>$selected){
echo '<option value="'.$month.'"'.$selected.'>'.$month.'</option>';
}
echo '</select>';
--
regards,
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php