I have a drop down box getting values from mysql, mysql contains all months and an id for each e.g. 01 -12
I want to get the month it is currently as the pre-selected value in my drop down box
I use $numbermonth = date("m");
So if it's january the id field will be 01 and the above function will return 01.
Now, the research I have done on default selection tells me it is something to do putting selected somewhere. I have tried to add an if statement within this while statement to test if $data2[id] == $numbermonth but with no success.
Expand|Select|Wrap|Line Numbers
- while ($data2=mysql_fetch_assoc($result2))
- {
- echo "<option value=\"", $data2['month'] selected, "\">", $data2['month'], "</option>" . "<br />";
- }
- ?>
Regards
B