postgres
06-05-2012, 18:24
Salve ho trovato questo codice per crearea un menų a tendina per la visualizzazione di una data.
<?php
$html_output = ' <div id="date_select" >'."\n";
$html_output .= ' <label for="date_day"> </label>'."\n";
/*days*/
$html_output .= ' <select name="date_day" id="day_select">'."\n";
for ($day = 1; $day <= 31; $day++) {
$html_output .= ' <option>' . $day . '</option>'."\n";
}
$html_output .= ' </select>'."\n";
/*months*/
$html_output .= ' <select name="date_month" id="month_select" >'."\n";
$months = array("", "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");
for ($month = 1; $month <= 12; $month++) {
$html_output .= ' <option value="' . $month . '">' . $months[$month] . '</option>'."\n";
}
$html_output .= ' </select>'."\n";
/*years*/
$html_output .= ' <select name="date_year" id="year_select">'."\n";
for ($year = 2012; $year <= (date("Y") ); $year++) {
$html_output .= ' <option>' . $year . '</option>'."\n";
}
$html_output .= ' </select>'."\n";
$html_output .= ' </div>'."\n";
?>
<form action="" method="post">
<?php
echo "Data:".date_dropdown();
#echo date_dropdown();
?>
<input type="submit" name="submit" value="Ricerca"/>
</form>
Ora vorrei capire, per quanto possa sembrare banale, come fare a memorizzare la scelta dell'utente in una variabile!
se stampo month esce 13
i $_POST non servono a niente.
Come va preso il valore selezionato?
<?php
$html_output = ' <div id="date_select" >'."\n";
$html_output .= ' <label for="date_day"> </label>'."\n";
/*days*/
$html_output .= ' <select name="date_day" id="day_select">'."\n";
for ($day = 1; $day <= 31; $day++) {
$html_output .= ' <option>' . $day . '</option>'."\n";
}
$html_output .= ' </select>'."\n";
/*months*/
$html_output .= ' <select name="date_month" id="month_select" >'."\n";
$months = array("", "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");
for ($month = 1; $month <= 12; $month++) {
$html_output .= ' <option value="' . $month . '">' . $months[$month] . '</option>'."\n";
}
$html_output .= ' </select>'."\n";
/*years*/
$html_output .= ' <select name="date_year" id="year_select">'."\n";
for ($year = 2012; $year <= (date("Y") ); $year++) {
$html_output .= ' <option>' . $year . '</option>'."\n";
}
$html_output .= ' </select>'."\n";
$html_output .= ' </div>'."\n";
?>
<form action="" method="post">
<?php
echo "Data:".date_dropdown();
#echo date_dropdown();
?>
<input type="submit" name="submit" value="Ricerca"/>
</form>
Ora vorrei capire, per quanto possa sembrare banale, come fare a memorizzare la scelta dell'utente in una variabile!
se stampo month esce 13
i $_POST non servono a niente.
Come va preso il valore selezionato?