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

    <tfoot id='Ceoyy'></tfoot>

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

        从 MySQL 生成下拉菜单

        Generate Drop Down From MySQL(从 MySQL 生成下拉菜单)

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

              1. <small id='HzUxZ'></small><noframes id='HzUxZ'>

                  <tbody id='HzUxZ'></tbody>

                • <bdo id='HzUxZ'></bdo><ul id='HzUxZ'></ul>
                  <legend id='HzUxZ'><style id='HzUxZ'><dir id='HzUxZ'><q id='HzUxZ'></q></dir></style></legend>
                  <tfoot id='HzUxZ'></tfoot>
                • 本文介绍了从 MySQL 生成下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要从 MySQL 表中的数据生成一个下拉菜单.

                  I need to generate a drop down menu from data in a MySQL table.

                  从表中,它必须获取用户 ID 和用户名.

                  From the table, it'll have to take the user id and the username.

                  然后它将用户 ID 设置为选项值,并将用户名设置为下拉列表中显示的内容.

                  Then it'll set the user id to option value and the username to what shows up in the drop down.

                  谁能给我看一些代码?我在进行以下工作时遇到问题:

                  Could anyone show me some code for it? I'm having trouble making the following work:

                  $sql = "SELECT user_id, user_name FROM users";
                  $result = mysql_query($sql);
                  
                  while($row = mysql_fetch_array($result))
                  {
                    echo "<option value=".$row['user_id'].">.$row['user_name'].</option>
                   ";
                    echo "<option value="12275">".$row['user_name']."</option>
                   ";
                  }
                  

                  推荐答案

                  您的输出有几个问题.首先,从您的示例中不清楚您是否有实际的 select 元素父元素,而且我不确定浏览器是否会在没有父元素选择的情况下显示 options .其次,您没有转义数组变量.所以这可能会解决它:

                  You have a couple of issues with your output. First, it's not clear from your example if you have the actual select element parent, and I'm not sure if browsers will display options without a parent select. Second, you are not escaping your array variables. So this might fix it:

                  $sql = "SELECT user_id, user_name FROM users"; $result=mysql_query($sql);
                  
                  echo '<select name="users">';
                  
                  while($row = mysql_fetch_array($result)) {
                      echo '<option value="'. $row['user_id'] . '">' . $row['user_name'] . "</option>
                  ";
                  }
                  
                  echo '</select>';
                  

                  这篇关于从 MySQL 生成下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Appending GET parameters to URL from lt;formgt; action(将 GET 参数附加到来自 lt;formgt; 的 URL行动)
                  Forcing quot;Save Asquot; dialog via jQuery GET(强制“另存为通过 jQuery GET 对话框)
                  PHP - get certain word from string(PHP - 从字符串中获取某个单词)
                  How to debug a get request in php using curl(如何使用 curl 在 php 中调试 get 请求)
                  get a # from a url in php(从 php 中的 url 获取 #)
                  PHP - include() file not working when variables are put in url?(PHP - 将变量放入 url 时,include() 文件不起作用?)
                    • <bdo id='rD9p9'></bdo><ul id='rD9p9'></ul>
                      <legend id='rD9p9'><style id='rD9p9'><dir id='rD9p9'><q id='rD9p9'></q></dir></style></legend>

                      <tfoot id='rD9p9'></tfoot>
                    • <small id='rD9p9'></small><noframes id='rD9p9'>

                            <tbody id='rD9p9'></tbody>

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