Una función estándar para pedir un campo de fecha en un formulario PHP.
- /**
- * Devuelve los 3 campos de Fecha: Dia-mes-año
- *
- * @return unknown
- */
- function file_date($dia=0,$mes=0,$any=0)
- {
- $str ="";
- // Campo día
- $str.="<select name='dia'>";
- $ind = 1;
- while ( $ind < 32 )
- {
- $str.= "<option value='$ind";
- if ($dia == $ind)
- {
- $str.="' selected>" ; // Es el día por defecto
- }
- else
- {
- $str.="'>" ;
- }
- $str.="$ind</option>";
- $ind++;
- }
- $str.="</select> ";
- // Campo mes
- $str.="<select name='mes'>";
- $ind = 1;
- while ( $ind < 13 )
- {
- $str.= "<option value='$ind";
- if ($mes == $ind)
- {
- $str.="' selected>" ; // Es el día por defecto
- }
- else
- {
- $str.="'>" ;
- }
- $str.= mes_txt($ind)."</option>";
- $ind++;
- }
- $str.="</select> ";
- // Campo any
- $str.="<select name='any'>";
- $ind = 1936;
- while ( $ind < 2006 )
- {
- $str.= "<option value='$ind";
- if ($any == $ind)
- {
- $str.="' selected>" ; // Es el día por defecto
- }
- else
- {
- $str.="'>" ;
- }
- $str.= "$ind</option>";
- $ind++;
- }
- $str.="</select>";
- return $str;
- }













