Drop down menu 选择框当值来自db时如何设置第一个值

Drop down menu 选择框当值来自db时如何设置第一个值,drop-down-menu,Drop Down Menu,我正在用数据库中的值制作一个选择框,我希望第一个值是“做出选择” 怎么能做到? 我有这个密码 <tr> <td width="180" height="30"><label for="valgtkon" class="labelLeft">Vælg konkurrencetype</label></td> <td><sel

我正在用数据库中的值制作一个选择框,我希望第一个值是“做出选择”

怎么能做到? 我有这个密码

                <tr>
                <td width="180" height="30"><label for="valgtkon" class="labelLeft">Vælg konkurrencetype</label></td> 
                <td><select id="valgtTitel" name="valgtTitel" onchange="run()">                  
                <?php
                $virksomhedsID = $_SESSION['virkID'];
                $sql = "SELECT * FROM konkurrenceType ORDER BY konkurrenceType.kontypeID";
                $result = mysql_query($sql) or die(mysql_error());                  

                while($rowSelect = mysql_fetch_assoc($result))
                { 
                    $kontypeTitel = $rowSelect['kontypeTitel'];
                    $kontypeID = $rowSelect['kontypeID'];

                    echo '<option value="' . $kontypeID . '">' . $kontypeTitel . '</option>';
                }?>                    
                </select></td>
                <script>
                function run() {
                    document.getElementById("valgtID").value = document.getElementById("valgtTitel").value;
                }
                </script>


                <td><input type="text" name="valgtID" id="valgtID"/></td>
                </tr>

Vælg konkurrencetype
函数运行(){
document.getElementById(“valgtID”).value=document.getElementById(“valgtitel”).value;
}

在数据库结果之前设置选项首先设置选项,因此将其放置在php之外的选择标记之后,这应该可以做到

粗体文本必须表示标记。
(我的iphone上有即时消息)

在while循环之前,添加另一个echo语句,为第一个“做出选择”选项创建选项,然后在提交时添加一些验证,以确保他们从列表中选择了不同的选项。

Jep我得到了它。多谢各位

            <tr>
                <td width="180" height="30"><label for="valgtkon" class="labelLeft">Vælg konkurrencetype</label></td> 
                <td><select id="valgtTitel" name="valgtTitel" onchange="run()">                  
                <?php
                $virksomhedsID = $_SESSION['virkID'];
                $sql = "SELECT * FROM konkurrenceType ORDER BY konkurrenceType.kontypeID";
                $result = mysql_query($sql) or die(mysql_error());                  

                echo '<option value="Vælg type">Vælg type</option>';

                while($rowSelect = mysql_fetch_assoc($result))
                { 
                    $kontypeTitel = $rowSelect['kontypeTitel'];
                    $kontypeID = $rowSelect['kontypeID'];

                    echo '<option value="' . $kontypeID . '">' . $kontypeTitel . '</option>';
                }?>                    
                </select></td>
                <script>
                function run() {
                    document.getElementById("valgtID").value = document.getElementById("valgtTitel").value;
                }
                </script>


                <td><input type="text" name="valgtID" id="valgtID"/></td>
                </tr>

Vælg konkurrencetype
函数运行(){
document.getElementById(“valgtID”).value=document.getElementById(“valgtitel”).value;
}