欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

利用php创建日期选择框

程序员文章站 2022-04-13 14:09:54
...
<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>