【问题标题】:data not fetching into dropdown数据未提取到下拉列表中
【发布时间】:2019-07-06 19:54:35
【问题描述】:

我正在尝试从我的数据库中获取一些数据到下拉列表中。但它不起作用。这是我的代码。谢谢

<div class="col-md-5">
   <select multiple class="form-control" style="height: 100px" id="experienceEdit">
     <?php
         $sqlVessel = "SELECT * FROM vessel_types ORDER BY vessel_types ASC";
         $resultVessel = $conn->query($sqlVessel);

         if ($resultVessel->num_rows > 0) {
              // output data of each row
              while ($rowVessel = $resultVessel->fetch_assoc()) {
      ?>
      <option class="experienceValEdit"  value="<?php echo $rowVessel['idvessel_types']; ?>"><?php echo $rowVessel['vessel_types']; ?></option>
      <?php
            }
               } else {

               }
      ?>

【问题讨论】:

  • 写下你的表中有哪些字段?
  • @MikeFoxtech 感谢您的评论。仅限idvessel_typesvessel_types
  • 表中有数据吗?
  • 是的,有 7 个数据
  • 可能会或可能不会帮助您解决问题,但无需检查 num 行。让while 做它的事。

标签: php html frontend


【解决方案1】:

检查这一行。

  if ($resultVessel->num_rows > 0) {

应该有一个-

我认为这应该会产生一些错误。不是吗?@usinshif

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-18
    • 2021-11-02
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2020-12-02
    相关资源
    最近更新 更多