More Date Selection
Normally, we want a date picking tool to have a specific date preselected. Often the preselected date is the current one. Sometimes it needs to match a record in a database. Either way, we need a way of making the previous form a little more useful.
Here is an example of the HTML required to produce a dropdown box with an item preselected,
<option value='two' selected='SELECTED'>Two</option>
To preselect an option, we add an attribute, selected='SELECTED'.
In order to know which items to select, our script would need to know the current date. The following PHP shows how to find and display the information we need.
$today = getdate();
echo "<p>Day ";
echo "<br>Month ";
echo "<br>Year ";
We need to adapt the code we used to produce the original date selection form. The following shows how the code to display the month day can be shown.
echo "<p>Day: <select name='day'>";
echo "<option value='".$i."' selected='SELECTED'>".$i."</option>\n";
echo "<option value='".$i."'>".$i."</option>\n";
Once you have made sure that the other dropdown boxes have appropriate preselections, the next step would be to do something with the information that is submitted on the form.
One idea would be to use the PHP documentation to find out how to display the day of the week that corresponds to the date selected on the form.