Home >Backend Development >PHP Tutorial >Create date selection box using php

Create date selection box using php

巴扎黑
巴扎黑Original
2016-12-01 10:28:073923browse

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn