当前位置:Gxlcms > PHP教程 > 利用php创建日期选择框

利用php创建日期选择框

时间:2021-07-01 10:21:17 帮助过:3人阅读

<form action="" method="post" >
<?php
$months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$days = range(1,31);
$years = range(2008,2018);
echo '<select name="month" >';
foreach ($months as $key => $value) {
echo "<option value=\"$key\">$value</option>";
}
echo '</select>';
echo '<select name="day" >';
foreach ($days as $value) {
echo "<option value=\"$value\">$value</option>";
}
echo '</select>';
echo '<select name="year" >';
foreach ($years as $value) {
echo "<option value=\"$value\">$value</option>";
}
echo '</select>';
?>
</form>

人气教程排行