On 5/21/06, Paul Goepfert <paul.goepfert@xxxxxxxxx> wrote:
Hi all, 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"]; echo("<option selected=" . date("F") . "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
I see Paul N. solved your selection problem. But I'm wondering why you need to store month names in a database. You could get them using date() and mktime() and avoid a db hit: foreach (range(1, 12) as $i) { echo date('F', mktime(0, 0, 0, $i)); } Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php