In an attempt to use selection lists in php ,i tried it for displaying date on a web page
<?php
echo"<html>
<head><title>Select a Date </title></head>
<body>";
$monthname=array(1=>"January","Februray","March","April","May","June","July","August","September","October","November","December");
$time=time();
$today_date=date("M-d-Y",$time); //returns the current date
echo "<div style='text-align:center'>\n";
echo "<h3>Today is $today_date</h3><hr />\n";
echo "<form action='process_form_date.php' method='POST'>\n";
//selection list for month
$todayMO=date("M",$time); //returns the current month
echo "<select name='dateMonth'>\n";
for ($M=1;$M<=12;$M++)
{
echo "<option value = $M";
if($todayMO == $M)
echo "selected";
echo "> $monthname[$M]\n</option>";
}
echo "</select>\n";
//selection list for day
$todayDay=date("d",$time);
echo "<select name='dateDay'>\n";
for($n=1;$n<=31;$n++)
{
echo "<option value = $n";
if($todayDay == $n)
echo "selected";
echo ">$n</option>\n";
}
echo "</select>\n";
//selection list for year
$todayYear=date("y",$time);
echo "<select name='dateYear'>\n";
for($n=$todayYear;$n<=$todayYear+3;$n++)
{
echo "<option value = $n";
if($todayYear == $n)
echo "selected";
echo ">$n</option>\n";
}
echo "</select>\n";
echo "</form></div>\n";
?>
</body>
</html>
But this code is not using the 'select' option to display today's date in a selection list but rather displaying for me
January-1-2014(default in code.)
How to get it?