php代码中的select标签与下一个<h2>标签重叠

时间:2019-03-23 12:09:12

标签: php html css mysql

我尝试创建不同的div标签,但是PHP代码中的select标签仍然与之重叠。我什至尝试使用

<body>
  <header>
    <div class="bgimg">
      <?php include('includes/navbar.php') ?>
      <form onsubmit="" action="changeemployee.php" method="POST">
        <div class="row text-white m-auto">
          <div class="col-lg-4 col-md-4 col-sm-12">
            <h2 class="text-center">Select Username</h2>
            <label>Select Employee's Username</label>
            <?php
              $query = "SELECT empusername FROM empcredential";
              $result = mysqli_query($db, $query);
              echo "<select class='custom-select' name='empusername'>";
              while($row = mysqli_fetch_array($result))
              {
                echo "<option value='".$row['empusername']."'>".$row['empusername']."</option>";
              }
            ?>
          </div>
          <div class="col-lg-4 col-md-4 col-sm-12">
            <!--Corresponding Address-->
            <h2 class="text-center">Corresponding Address</h2>
            <label for="empcoraddress">Address</label>
            <input type="text" class="form-control" id="empcoraddress" name="empcoraddress" required>
            <label for="empcorctv">City/Town/Village</label>
</div>````

1 个答案:

答案 0 :(得分:1)

我认为您忘了关闭选择标签

<?php
     $query = "SELECT empusername FROM empcredential";
     $result = mysqli_query($db, $query);
     echo "<select class='custom-select' name='empusername'>";
         while($row = mysqli_fetch_array($result))
           {
             echo "<option value='".$row['empusername']."'>".$row['empusername']."</option>";
           }
     echo "</select>";
?>