php - Bootstrap nav-tabs 不适用于 php 脚本

标签 php html css twitter-bootstrap twitter-bootstrap-3

我的导航标签在我的下拉列表中使用静态数据时工作正常,但是当我添加脚本来填充下拉列表时,标签不再工作。

我认为查询没有任何问题,因为列表已填充。可能是 echo ?

          <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#tab_1" data-toggle="tab">Boarding House Info</a></li>
              <li><a href="#tab_2" data-toggle="tab">Other Info</a></li>
              <li><a href="#tab_3" data-toggle="tab">Location</a></li>
            </ul>

            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
                <div class="box-body">
                  <div class="form-group">
                    <label for="boarding-house-name">Boarding House Name</label>
                    <input type="text" class="form-control" id="bh-name" name="bh-name" placeholder="boarding house name">
                  </div>
                  <div class="form-group" style="margin-bottom:50px">
                    <label for="price">Price</label><br>
                    <div class="col-md-2" style="margin-left:-15px;">
                      <input type="text" class="form-control" id="pricemin" name="bh-pricemin" placeholder="min">
                    </div>
                    <div class="col-md-2" style="margin-left:-15px;">
                      <input type="text" class="form-control" id="pricemax" name="bh-pricemax" placeholder="max">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="address">Address</label>
                    <input type="text" class="form-control" id="address" name="bh-address" placeholder="address">
                  </div>
                  <div class="form-group">
                    <label for="barangay">Barangay</label>
                      <select class="form-control" name="bh-barangay">
                        <option value="Brgy 1">Brgy 1</option>
                        <option value="Brgy 2">Brgy 2</option>
                        <option value="Brgy 3">Brgy 3</option>
                        <option value="Brgy 4">Brgy 4</option>
                      </select>
                  </div>
                  <div class="form-group">
                    <label for="contactperson">Contact Person</label>
                    <input type="text" class="form-control" id="contactperson" name="bh-contactperson" placeholder="contact person">
                  </div>
                  <div class="form-group">
                    <label for="contactnumber">Contact Number</label>
                    <input type="text" class="form-control" id="contactnumber" name="bh-contactnumber" placeholder="contact number">
                  </div>
                  <div class="form-group">
                    <label for="owner">Owner</label>
                    <select class="form-control" name="bh-owner-id">
                      <?php 
                        $query = "SELECT id_owner, owner_name FROM tbl_owner";
                        $result = $conn->query($query) or die("Connection failed: " . $conn->connect_error);

                        while($row = mysqli_fetch_assoc($result)) {
                          echo "<option value='".$row['id_owner']."'>".$row['owner_name']."</option>";
                        } mysql_free_result($result);
                      ?>
                    </select>
                  </div>
                </div>
              </div>

              <div class="tab-pane" id="tab_2">
                <div class="box-body">
                  <div class="form-group">
                    <label for="tenant" style="margin-bottom:-15px;">Tenant</label>
                    <div class="checkbox">
                      <label class="checkbox-inline">
                        <input type="checkbox" id="tenant_checkbx" value="Male"> Male
                      </label>
                      <label class="checkbox-inline">
                        <input type="checkbox" id="tenant_checkbx" value="Female"> Female
                      </label>
                    </div>
                  </div>
                  <div class="form-group" style="margin-bottom:50px">
                    <label for="specification">Specification</label><br>
                    <div class="col-md-6" style="margin-left:-15px;">
                      <select class="form-control">
                        <option>Boarding House</option>
                        <option>Dormitory</option>
                        <option>Apartelle</option>
                        <option>Lodge</option>
                        <option>Motel</option>
                      </select>
                    </div>
                  </div>
                  <div class="form-group" style="margin-bottom:50px">
                    <label for="noofrooms">No. of Rooms</label><br>
                    <div class="col-md-6" style="margin-left:-15px;">                          
                      <input type="text" class="form-control" id="exampleInputEmail1" placeholder="# of rooms">
                    </div>
                  </div>
                  <div class="col-md-2">
                    <div class="form-group" style="margin-left:-15px;">
                      <label for="curfew">Curfew</label>                    
                      <div class="radio">
                        <label>
                          <input type="radio" name="curfew_radio" id="curfew_yes" value="Yes" checked> Yes
                        </label>
                      </div>
                      <div class="radio">
                        <label>
                          <input type="radio" name="curfew_radio" id="curfew_no" value="No"> No                            
                        </label>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-2">
                    <div class="form-group" style="margin-left:-15px;">
                      <label for="guests">Guests</label>
                      <div class="radio">
                        <label>
                          <input type="radio" name="guests_radio" id="guests_yes" value="Yes" checked> Yes
                        </label>
                      </div>
                      <div class="radio">
                        <label>
                          <input type="radio" name="guests_radio" id="guests_no" value="No"> No
                        </label>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-2">
                    <div class="form-group" style="margin-left:-15px;">
                      <label for="crtype">CR Type</label>
                      <div class="checkbox">
                        <label>
                          <input type="checkbox" id="crtype_checkbx" value="Private"> Private
                        </label>
                      </div>
                      <div class="checkbox">
                        <label>
                          <input type="checkbox" id="crtype_checkbx" value="Public"> Public
                        </label>
                      </div>
                    </div>   
                  </div>             
                </div>
              </div>

              <div class="tab-pane" id="tab_3">
                <div class="box-body">
                  <!-- INSERT MAP HERE -->            
                </div>
              </div>

            </div>
          </div>

这是我用来填充所有者下拉列表的查询 php 脚本:

                      <?php 
                        $query = "SELECT id_owner, owner_name FROM tbl_owner";
                        $result = $conn->query($query) or die("Connection failed: " . $conn->connect_error);

                        while($row = mysqli_fetch_assoc($result)) {
                          echo "<option value='".$row['id_owner']."'>".$row['owner_name']."</option>";
                        } mysql_free_result($result);
                      ?>

最佳答案

它现在正在工作。对脚本进行了更多调试,似乎是这样一行:

mysql_free_result($result);

(在 while 条件之后)是罪魁祸首。

我删除了它,标签现在可以使用了。 :)

关于php - Bootstrap nav-tabs 不适用于 php 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45852040/

相关文章:

php - Yii,我正在尝试为我的 View 设置一个动态布局

php - php从mysql访问数据时的奇怪查询

php - 我如何在购物车图标后面显示购物车中的总元素

html - Bootstrap Image 无法设置宽度

css - child 主题CSS类问题

html - 试图整理 CSS 网格布局时遇到了困难

javascript - 删除div并带有漂亮的动画

php - 代码是否符合 Liskov 替换原则?

javascript - jQuery 将选择选项移动到第二个位置

php - 自动编号 Php 表单字段