我的桌子上有一些这样的字段:

Field Name   |   DataType    | Length  |
----------------------------------------
NAME         |   VARCHAR     |   50    |


我这样填写这张表:

NAME         |
--------------
Irfan        |
Lusye Agnes  |
Helda        |


因此,我在codeigniter中使用php来获取数据,然后在“选择选项”中将其查看为html。代码是这样的:

<div class="control-group">
  <label class="control-label" for="selectError1">Addressed To :</label>
     <div class="controls">
       <select id="selectError1" multiple data-rel="chosen" class="input-xlarge">
    <?php
       foreach ($datas as $data) {
         echo "<option value=" .$data['Name']. " >" . $data['Name'] . "</option>";
       }
    ?>

    </select>
   </div>
  </div>


我使用firebug调试代码。
问题是,在田野中有“ Lusye agnes”之类的空间时,萤火虫的标识如下:

<select id="selectError1" class="input-xlarge chzn-done" data-rel="chosen"">
   <option value="Irfan">Irfan </option>
   <option agnes="" value="Lusye">Lusye Agnes</option>
   <option value="Helda">Helda</option>
</select>


我该如何纠正?

最佳答案

您是否正在寻找这样的东西:

<div class="control-group">
  <label class="control-label" for="selectError1">Addressed To :</label>
     <div class="controls">
       <select id="selectError1" multiple data-rel="chosen" class="input-xlarge">
    <?php
       foreach ($datas as $data) {
         echo "<option value='".$data['Name']."'>".$data['Name']."</option>";
       }
    ?>

    </select>
   </div>
  </div>

08-25 18:15