These are the functions I use when I want a date selection set in my pages
#Start Day option box
function day_choice(){
$days = range(1,31,1);
$day_choice='<select name ="day">';
foreach ($days as $value) {
$day_choice .="<option value =$value>$value</option>";
}
$day_choice .= '</select>';
print $day_choice;
}
#Start Month option box
function month_choice(){
$month = array(1=>'January','February','March','April','May','June','July','August','Aeptember','October','November','December');
$month_choice='<select name ="month">';
foreach ($month as$key => $value) {
$month_choice .="<option value =$key>$value</option>";
}
$month_choice .= '</select>';
print $month_choice;
}
#Start Year option box
function year_choice(){
$thisyear = getdate();
$year = range($thisyear['year'],1920,-1);
$year_choice='<select name ="year">';
foreach ($year as$value) {
$year_choice .="<option value =$value>$value</option>";
}
$year_choice .= '</select>';
print $year_choice;
}
And I would use them like this:
print '<form method="post">';
day_choice();
month_choice();
year_choice();
print '<input type="submit" name ="submit" value="Enter">
</form>';
if (isset($_POST['submit'])) {
function prettyprint($array){
print '<pre>';
print_r($array);
print '</pre>';
}
prettyprint($_POST);
}
The prettyprint() is just to show whats returned in the $_POST variable and wouldn't be used in the final page.