Re: selecting current month from a database

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

 



On Sun, May 21, 2006 1:45 am, Paul Goepfert wrote:
> I know this might be trivial problem but I can't seem to figure it
> out.  Here is my problem I have a drop down menu where I have the
> months of year as menu items.  I want to be able to have the current
> month be the selected month.  I have tried using the date function as
> the way to set the current month as the selected value but it seems
> that every value entered in the select box is set to selected.
>
> Here is my code maybe someone can help me out
>
>  $month_query = mysql_query("SELECT m_id, months FROM Month");
> 	while ($r = mysql_fetch_array($month_query))
> 	{
> 		$v = $r["m_id"];
> 		$out = $r["months"];


                $selected = $v == date("F") ? ' selected="selected"' :
'';
>// 		echo("<option  selected=" . date("F") .
"value=$v>$out</option>\n");
                echo "<option $selected value=\"$v\">$out</option>\n";

> 	}
>
> Just incase you want to know
>
> m_id = 1..12
> months = January..December
>
> How do I set only the current month to selected ?
>
> Thanks,
> Paul
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

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