无法从select标签获取$ _POST数组的值

时间:2016-07-21 11:20:34

标签: php html arrays

我有这个来自我的,我从其他输入标签和复选框获取值,但没有从$ _POST数组中的select标签获取值 这是代码

<select class="selectpicker form-control" name="fcity"  value="<?php echo $res['f_city'];?>" data-live-search="true" data-width="100%" title="Choose one of the following...">
<option data-tokens="Lahore" <?php echo ($res['f_city']=='Lahore')?'selected':'' ?>>Lahore</option>
<option data-tokens="Islamabad" <?php echo ($res['f_city']=='Islamabad')?'selected':'' ?>>Islamabad</option>
<option data-tokens="Karachi" <?php echo ($res['f_city']=='Karachi')?'selected':'' ?>>Karachi</option>
      </select>

1 个答案:

答案 0 :(得分:0)

我认为您需要在每个'选项'标记上添加'value'属性,而不是在'select'标记中

e.g:

<option value="Lahore" data-tokens="Lahore" <?php echo ($res['f_city']=='Lahore')?'selected':'' ?>>Lahore</option>