<legend id='SKL6O'><style id='SKL6O'><dir id='SKL6O'><q id='SKL6O'></q></dir></style></legend>

    <tfoot id='SKL6O'></tfoot>

    1. <i id='SKL6O'><tr id='SKL6O'><dt id='SKL6O'><q id='SKL6O'><span id='SKL6O'><b id='SKL6O'><form id='SKL6O'><ins id='SKL6O'></ins><ul id='SKL6O'></ul><sub id='SKL6O'></sub></form><legend id='SKL6O'></legend><bdo id='SKL6O'><pre id='SKL6O'><center id='SKL6O'></center></pre></bdo></b><th id='SKL6O'></th></span></q></dt></tr></i><div id='SKL6O'><tfoot id='SKL6O'></tfoot><dl id='SKL6O'><fieldset id='SKL6O'></fieldset></dl></div>

      <small id='SKL6O'></small><noframes id='SKL6O'>

        <bdo id='SKL6O'></bdo><ul id='SKL6O'></ul>

      如何使用数据库中的值填充 HTML 下拉列表

      时间:2023-09-20
          <tbody id='xliM8'></tbody>
        <i id='xliM8'><tr id='xliM8'><dt id='xliM8'><q id='xliM8'><span id='xliM8'><b id='xliM8'><form id='xliM8'><ins id='xliM8'></ins><ul id='xliM8'></ul><sub id='xliM8'></sub></form><legend id='xliM8'></legend><bdo id='xliM8'><pre id='xliM8'><center id='xliM8'></center></pre></bdo></b><th id='xliM8'></th></span></q></dt></tr></i><div id='xliM8'><tfoot id='xliM8'></tfoot><dl id='xliM8'><fieldset id='xliM8'></fieldset></dl></div>

        <small id='xliM8'></small><noframes id='xliM8'>

        • <bdo id='xliM8'></bdo><ul id='xliM8'></ul>
          <legend id='xliM8'><style id='xliM8'><dir id='xliM8'><q id='xliM8'></q></dir></style></legend>

          • <tfoot id='xliM8'></tfoot>

                本文介绍了如何使用数据库中的值填充 HTML 下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                作为我正在创建的 HTML 表单的一部分,我想要一个下拉列表,该列表将列出我数据库中的所有用户名.

                as part of a HTML form I am creating I would like to have a dropdown list which will list all the usernames in my database.

                我认为以下代码可以解决问题,但下拉列表是空的 - 有人可以帮助我解决我做错了什么吗?谢谢.

                I thought the following code would do the trick but the dropdown list is empty - could someone assist me in what i'm doing wrong? Thanks.

                <tr>
                <td>Owner</td>
                <td>
                <select name="owner">
                <?php 
                
                $sql = mysqli_query($connection, "SELECT username FROM users");
                
                while ($row = $sql->fetch_assoc()){
                
                ?>
                <option value="owner1"><?php echo $row['username']; ?></option>
                
                <?php
                // close while loop 
                }
                ?>
                </td>
                </tr>
                

                推荐答案

                我猜你有问题,因为你没有在循环后关闭你的选择标签.这能解决问题吗?

                My guess is that you have a problem since you don't close your select-tag after the loop. Could that do the trick?

                <select name="owner">
                <?php 
                $sql = mysqli_query($connection, "SELECT username FROM users");
                while ($row = $sql->fetch_assoc()){
                echo "<option value="owner1">" . $row['username'] . "</option>";
                }
                ?>
                </select>
                

                这篇关于如何使用数据库中的值填充 HTML 下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在 NetBeans 中添加带有点 (blade.php) 的自定义文 下一篇:while循环中的php sum变量

                相关文章

                最新文章

                1. <tfoot id='d2OkW'></tfoot>
                  1. <legend id='d2OkW'><style id='d2OkW'><dir id='d2OkW'><q id='d2OkW'></q></dir></style></legend>

                    <small id='d2OkW'></small><noframes id='d2OkW'>

                      <bdo id='d2OkW'></bdo><ul id='d2OkW'></ul>

                  2. <i id='d2OkW'><tr id='d2OkW'><dt id='d2OkW'><q id='d2OkW'><span id='d2OkW'><b id='d2OkW'><form id='d2OkW'><ins id='d2OkW'></ins><ul id='d2OkW'></ul><sub id='d2OkW'></sub></form><legend id='d2OkW'></legend><bdo id='d2OkW'><pre id='d2OkW'><center id='d2OkW'></center></pre></bdo></b><th id='d2OkW'></th></span></q></dt></tr></i><div id='d2OkW'><tfoot id='d2OkW'></tfoot><dl id='d2OkW'><fieldset id='d2OkW'></fieldset></dl></div>