RE: selecting current month from a database

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

 



At 06:32 AM 5/22/2006, Jef Sullivan wrote:
$cur_month = date("m");
while ($r = mysql_fetch_array($month_query))
{
        $v = $r["m_id"];
      $out = $r["months"];
        if( $cur_month = $v )
        {
                echo("<option  selected=".$cur_month.
"value=".$v.">".$out."</option>")
        }
        ....
}


You're definitely saving some server machine cycles there by calculating the current month just once.

On the other hand, your code would output an option only when the data month matched the current month. I'm under the impression that the original poster wanted the user to be able to select from a list of different months. Therefore I'd echo the option tag with every iteration and include the selected attribute only when the month matched.

Paul
--
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