选择多个框中的选定值

时间:2018-01-22 01:36:03

标签: php html

    $excludeship = unserialize($data[0]['exclush']); //from database

    $excludecountry = ""; //data from API

$excludehtml =  <select multiple id="excludeship" name="excludeship" class="form-control excludeship">

  foreach ($excludeship as $key4 => $value4){    //from database
        foreach ($excludecountry as $key => $value){    //data from API             
            $excludehtml .= '<optgroup label='.$key.'>';
                    foreach ($value as $v){
                        if($v['value'] == $value4){                             
$excludehtml .=     '<option value='.$v['value']. selected>'.$v['Description'].'</option>';
                                }else{
                                     $excludehtml .= '<option value='.$v['value'].'>'.$v['Description'].'</option>';
                                }
                            }
                            $excludehtml .= '</optgroup>';                  
                        }
                    }
$excludehtml .=   </select>

result here

问题:上面的代码就是显示前端的选择框,我写的代码是与选项值重复的错误,但是可以选择该值。我可以知道如何选择该值并且选项数据不会重复吗?

0 个答案:

没有答案