Re: <OPTION

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 10/25/2006 04:09 PM, Stut wrote:
Dang that's painful!! Try this...

<?php
    foreach (range(1, 31) as $day)
    {
        print '<option value="'.$day.'"';
        if ($selected_day_of_month == $day)
            print ' selected';
        print '>'.$day.'</option>';
    }

?>


Ouch!  Gnarly mix of logic and markup.  I suggest something more like:

        foreach (range(1, 31) as $day)
        {
$sSelected = ($selected_day_of_month == $day) ? ' selected="selected"' : '';

                print <<< hdDay
                <option value="$day"$sSelected>$day</option>

hdDay;
        }

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux