如何在php下拉列表中使用选定的值?

时间:2018-05-04 06:51:28

标签: php

我在php中使用以下代码进行下拉列表

<!doctype html>
   <html>
   <body style='margin:0;padding:0;'>
    <div style="height:200px;background-color:red;">
    </div>

     <h1>Some other content</h1>
     <h1>Some other content</h1>
     <h1>Some other content</h1>
      <h1>Some other content</h1>
      <h1>Some other content</h1>
      <h1>Some other content</h1>
      <h1>Some other content</h1>
      <h1>Some other content</h1> 


      <!-- 
         use the br tag to create the white space up to the bottom 
         height to the bottom  you can control by the br tag
       -->
        <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />

     <div style="height:25px;background- 
      color:blue;display:block;color:white;margin-bottom:0;padding- 
        bottom:0;">
          footer   
           </div>

      </body>

      </html>

我在编辑表单中使用此代码。我想在下拉列表中使用选定的值($ iname)。如何在此代码中设置选定的值。此致

1 个答案:

答案 0 :(得分:0)

如果您想将此值$ iname与您的选项进行比较,请使用以下代码:

$edropdown .= "\r\n<option value='{$erow['name']}' ({$erow['name']}==$iname)?'selected':''>{$erow['name']}</option>";