【发布时间】:2018-08-03 17:53:37
【问题描述】:
如何从选择列表中获取选定的值?如何命名每个选项?我使用数组来检查可用性并回发到 index.php 但我无法获得选定的值,因为没有命名选定的值。
过滤器.php
$a=array(10,12,14,16,18,20);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$r=$row['res_time'];
if($r==12) $a[1] = 0;
else if($r==14) $a[2] = 0;
else if($r==16) $a[3] = 0;
else if($r==18) $a[4] = 0;
else if($r==20) $a[5] = 0;
}
echo'<label> Time: <select class="form-control" >';
for($x = 0; $x < count($a); $x++) {
if($a[$x]!=0) echo '<option>' .$a[$x] . '</option>';
else{
echo 'Full';}
}
echo'</select> </label>';
}
else
{
echo '<label> Time: <select class="form-control" >';
for($x = 0; $x < count($a); $x++) {
if($a[$x]>0) echo '<option >' .$a[$x] . '</option>';
}
echo'</select></label> </div>'; }
【问题讨论】:
-
你命名
select标签,而不是option
标签: php select drop-down-menu