当尝试使用php动态创建包含值的选择框时,我的数据将不会填充。我所做的所有研究都表明我做得对。任何人都可以指出我正确的方向。
<select name="month">
<?php
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
for ($x=0; $x<=11; $x++) {
echo '<option value="' . $x+1 . '">' . $months[$x] . '</option>';
}
?>
</select>
答案 0 :(得分:0)
你应该在$ x + 1
附近添加括号 像这样:<select name="month">
<?php
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
for ($x=0; $x<=11; $x++) {
echo '<option value="' . ($x+1) . '">' . $months[$x] . '</option>';
}
?>
</select>