dpoxk64080 2013-11-10 18:24
浏览 11
已采纳

如何摆脱下拉框中的额外行?

So I have looked for this here and other places and I can't fine a solution. I am working on a page that has several drop down boxes for staff members. I have use sql to get the names from the database and it works fine, aside from one small error. I am getting an extra space between the default Select a Staff Member and the first name on the 2nd call to this (see pic).

enter image description here

This is the code I have for that section of the page.

    <select name='contact1' class="reqd">
       <?php 
          echo "<option value='0' class='reqd'>-- Select a Staff Member --</option>";
          do {
              echo "<option value='".$row_staff['staffID']."'>".$row_staff['Name'] . "</option>" ; 
          }while ($row_staff = mysql_fetch_assoc($staff));
       mysql_data_seek($staff, 0);
    ?>
    </select>

I am using the same sql statement for the request hence the mysql_data_seek($staff, 0);. I can't see anything that would cause it to have an extra space. If I put mysql_data_seek($staff, 1); that just skips the first person.

Any ideas on what I need to fix?

  • 写回答

1条回答 默认 最新

  • dongye8110 2013-11-10 18:27
    关注

    any particular reason why to use do ... while loop instead of (more common) while?

       mysql_data_seek($staff, 0);
       while ($row_staff = mysql_fetch_assoc($staff)) {
           echo "<option value='".$row_staff['staffID']."'>".$row_staff['Name'] . "</option>" ; 
       };
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan