selecting current month from a database

From: Date: Sun, 21 May 2006 06:45:40 +0000
Subject: selecting current month from a database
Groups: php.general 
Request: Send a blank email to php-general+get-236565@lists.php.net to get a copy of this message
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

« previous php.general (#236565) next »