<bdo id='xthe6'></bdo><ul id='xthe6'></ul>
<tfoot id='xthe6'></tfoot>
  1. <legend id='xthe6'><style id='xthe6'><dir id='xthe6'><q id='xthe6'></q></dir></style></legend>

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

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

      如何在从 MySQL 数据库填充的 PHP 中创建动态下拉

      时间:2023-10-03

        1. <tfoot id='Tyqc7'></tfoot>

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

          • <bdo id='Tyqc7'></bdo><ul id='Tyqc7'></ul>
              <tbody id='Tyqc7'></tbody>

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

                <legend id='Tyqc7'><style id='Tyqc7'><dir id='Tyqc7'><q id='Tyqc7'></q></dir></style></legend>
              • 本文介绍了如何在从 MySQL 数据库填充的 PHP 中创建动态下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在尝试使用 PHP 和 mysql 数据库创建一个动态下拉列表.我编写了以下代码并给了我输出,但问题是它为每个项目显示不同的下拉菜单,我希望所有项目都在一个下拉列表中.请检查并指导我.

                I am trying to create a dynamic drop down list using PHP and mysql database. I have written the following code and its giving me the output, but the problem is that its showing different drop-down menu for each item, I want all items in a single drop down list. Kindly check it and guide me.

                        $select_query=          "Select name from category";
                        $select_query_run =     mysql_query($select_query);
                        while   ($select_query_array=   mysql_fetch_array($select_query_run) )
                        {
                            foreach ($select_query_array as $select_query_display)
                            {
                                echo "  
                                    <select>
                                        <option value='' >$select_query_display</option>                        
                                    </select>
                                ";
                
                
                                }
                
                            }
                

                谢谢

                推荐答案

                摆脱内部的 foreach 循环......它对你没有任何作用,并将开始和结束选择标签移到 while 循环之外.

                Get rid of the inner foreach loop... it is doing nothing for you and move the start and end select tags outside of the while loop.

                $select_query=          "Select name from category";
                $select_query_run =     mysql_query($select_query);
                echo "<select name='category'>";
                while ($select_query_array=   mysql_fetch_array($select_query_run) )
                {
                   echo "<option value='' >".htmlspecialchars($select_query_array["name"])."</option>";
                }
                echo "</select>";
                

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

                上一篇:基于另一个下拉选择过滤下拉 下一篇:<选择>下拉默认值

                相关文章

                最新文章

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

                <small id='3YGcG'></small><noframes id='3YGcG'>

                <legend id='3YGcG'><style id='3YGcG'><dir id='3YGcG'><q id='3YGcG'></q></dir></style></legend>
                <tfoot id='3YGcG'></tfoot>