Generate options by using user defined function
<?php
function generateOptions($start,$end,$inc){
$options = '';
for($i=$start; $i<=$end; $i+=$inc){
$options = $options."<option>".$i."</option>";
}
return $options;
}
?>
<select name="year">
<option>Year</option>
<?php
echo generateOptions(1900,date('Y')-10,1);
?>
</select>
function generateOptions($start,$end,$inc){
$options = '';
for($i=$start; $i<=$end; $i+=$inc){
$options = $options."<option>".$i."</option>";
}
return $options;
}
?>
<select name="year">
<option>Year</option>
<?php
echo generateOptions(1900,date('Y')-10,1);
?>
</select>
Comments
Post a Comment