1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4. <head>
5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6. <title>Date Menus</title>
7. </head>
8. <body>
9. <?php // Script 10.1 - menus1.php
10. /* This script defines and calls a function. */
11.
12. // This function makes three pull-down menus for the months, days, and years.
13. function make_date_menus() {
14.
15. // Array to store the months:
16. $months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
17.
18. // Make the month pull-down menu:
19. print '<select name="month">';
20. foreach ($months as $key => $value) {
21. print "\n<option value=\"$key\">$value</option>";
22. }
23. print '</select>';
24.
25. // Make the day pull-down menu:
26. print '<select name="day">';
27. for ($day = 1; $day <= 31; $day++) {
28. print "\n<option value=\"$day\">$day</option>";
29. }
30. print '</select>';
31.
32. // Make the year pull-down menu:
33. print '<select name="year">';
34. $start_year = date('Y');
35. for ($y = $start_year; $y <= ($start_year + 10); $y++) {
36. print "\n<option value=\"$y\">$y</option>";
37. }
38. print '</select>';
39.
40. } // End of make_date_menus() function.
41.
42. // Make the form:
43. print '<form action="" method="post">';
44. make_date_menus();
45. print '</form>';
46.
47. ?>
48. </body>
49. </html>