<tfoot id='TdQwA'></tfoot><legend id='TdQwA'><style id='TdQwA'><dir id='TdQwA'><q id='TdQwA'></q></dir></style></legend>
    1. <small id='TdQwA'></small><noframes id='TdQwA'>

      • <bdo id='TdQwA'></bdo><ul id='TdQwA'></ul>
      1. <i id='TdQwA'><tr id='TdQwA'><dt id='TdQwA'><q id='TdQwA'><span id='TdQwA'><b id='TdQwA'><form id='TdQwA'><ins id='TdQwA'></ins><ul id='TdQwA'></ul><sub id='TdQwA'></sub></form><legend id='TdQwA'></legend><bdo id='TdQwA'><pre id='TdQwA'><center id='TdQwA'></center></pre></bdo></b><th id='TdQwA'></th></span></q></dt></tr></i><div id='TdQwA'><tfoot id='TdQwA'></tfoot><dl id='TdQwA'><fieldset id='TdQwA'></fieldset></dl></div>
      2. PHP MySQL 下拉框填充选定值

        时间:2023-10-03
          <tbody id='zblAQ'></tbody>

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

          • <small id='zblAQ'></small><noframes id='zblAQ'>

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

            • <bdo id='zblAQ'></bdo><ul id='zblAQ'></ul>
                • 本文介绍了PHP MySQL 下拉框填充选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我已经阅读了有关如何使用 MySQL 填充整个下拉列表的教程,但我遇到的问题是我只想从数据库中获取一个并将其作为选定的一个.所以我想要一个下拉列表,其中包含数据库中的三个项目(Item1、Item2、Item3),它存储在一个名为 itemschoice 的列中,该列的值为Item2".当我加载下拉框时,如何让 item2 被选中?

                  I have read tutorials about how to populate an entire Drop down list with MySQL, but the problem I am running into is that I only want to grab the one from the database and have that be the selected one. So I would have like a drop down with three items (Item1, Item2, Item3) in the database its stored in a column called itemschoice which has a value of 'Item2'. How do I go about getting item2 to be selected when I load the drop down box?

                  推荐答案

                  在您的 元素中为 selected 属性添加 中的值>itemschoice.

                  In your <option> element add the selected attribute for the value that is in itemschoice.

                  使用组合函数获取选择的粗略示例:

                  Crude example using a made up function to get the choice:

                  $choice = get_items_choice();
                  $results = mysqli_query($sql);
                  
                  echo '<select name="whatever">';
                  while($row = mysqli_fetch_array($results)) {
                      if ($row['choice'] === $choice) {
                          echo '<option value="' . $choice . '" selected="selected" />';
                      } else {
                          echo '<option value="' . $choice . '" />';
                      }
                  }
                  echo '</select>';
                  

                  这只是一个例子,不要复制&粘贴此内容而不添加某种错误验证!

                  This is just an example, don't copy & paste this without adding some kind of error verification!

                  这篇关于PHP MySQL 下拉框填充选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PHP- 从数据库中获取并存储在下拉菜单 html 中 下一篇:如何从 PHP 数组中填充列表框/下拉框/选择框

                  相关文章

                  最新文章

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

                  <small id='02eCR'></small><noframes id='02eCR'>

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