Forum Moderators: open
Should i use a single column or more to hold the dates of the events?
which format should visitors enter the events dates
What is the mysql syntax for selecting only records which their dates has not passed
function date_list($name,$sy,$ey) {
//
$mm = $name . '_month';
$dd = $name . '_day';
$yy = $name . '_year';
$yearlen=$ey-$sy;
// Though $yearlen is not used, always good to error check
if (! ($yearlen>0)) { die("Invalid start or end year in date list"); }
//
$list .= '<select name="'.$mm.'" id="'.$mm.'">
<option value="">-</option>';
for ($i=1;$i<=12;$i++) {
$val=(strlen($i)==1)?'0'.$i:$i; // to get 01,02, etc.
$list .= '<option value="'.$val.'"';
if (isset($_POST[$mm]) and ($_POST[$mm]==$val)) {
// checked="checked" for XHTML
$list .= ' checked';
}
$list .= '>'.$val.'</option>';
}
$list .= '</select>
<select name="'.$dd.'" id="'.$dd.'">
<option value="">-</option>
';
// Don't care about invalid dates here, mySQL will
// handle it, if you want you can make this more robust
for ($i=1;$i<=31;$i++) {
$val=(strlen($i)==1)?'0'.$i:$i;
$list .= '<option value="'.$val.'"';
if (isset($_POST[$dd]) and ($_POST[$dd]==$val)) {
$list .= ' checked';
}
$list .= '>'.$val.'</option>';
}
$list .= '</select>
<select name="'.$yy.'" id="'.$yy.'">
<option value="">-</option>
';
for ($i=$sy;$i<=$ey;$i++) {
$list .= '<option value="'.$i.'"';
if (isset($_POST[$yy]) and ($_POST[$yy]==$i)) {
$list .= ' checked';
}
$list .= '>'.$i.'</option>';
}
$list .= '</select>';
return $list;
}