0

我正在使用此代码来 edit.php 以更新数据库,并且我在此字段中使用下拉框,但此代码不显示数据库值。它仅显示下拉框。>>>>选择<<<<

<tr>
   <td><div align="right"><strong>Password&nbsp;Encrypted:</strong></div></td>
   <td>
      <select name="txtENCRYPTED">
          <option value="">Select</option>
          <option <?php if ($objResult["ENCRYPTED"] == "Y") {echo 'selected';} ?>value="Y">Y</option>
          <option <?php if ($objResult["ENCRYPTED"] == "N") {echo 'selected';} ?> value="N">N</option>      
      </select>
  </td>
</tr> 
4

2 回答 2

0
 <option <?php if ($objResult["ENCRYPTED"] == "Y") {echo 'selected';} ?>value="Y">Y</option>

above will result in

<option selected value="Y">Y</option>

but you need this:

<option selected="selected" value="Y">Y</option>

so change to:

<option value="Y" <?php if ($objResult["ENCRYPTED"] == "Y") echo 'selected="selected"';?>>Y</options>
于 2013-10-10T08:58:24.377 回答
0

尝试这个

 <select name="txtENCRYPTED">
 <option value="Y" <?php if ($objResult["ENCRYPTED"] == "Y") echo 'selected="selected"';?>>Y</options>
 <option value="N" <?php if ($objResult["ENCRYPTED"] == "N") echo 'selected="selected"';?>>N</options>
 </select>
于 2013-10-10T08:55:02.487 回答