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>" ; 
       };
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?