如何使其他选项卡的内容与活动选项卡的工作方式相同?

How do I make the other tab content working the same as the active tab?

第一个选项卡工作正常,但是当我复制它并粘贴其他选项卡的内容时,它不起作用。我有一个显示当前日期的日期输入,但是 editable 选项卡内容也包含显示数据的 table。当您单击期中选项卡时,它不会在 table 内显示数据,日期也不会显示我在 javascript/jquery.

中使用的当前日期
 <div class="container">
            <div class="col-lg-12">
                <ul class="nav nav-tabs" role="tablist">
                    <li class="nav-item">
                        <a data-toggle="tab" class="nav-link active" href="#prelim">Prelim</a>
                    </li>
                    <li class="nav-item">
                        <a data-toggle="tab" class="nav-link" href="#midterm">Midterm</a>
                    </li>
                </ul>

                <!-- Tab panes -->
                <div class="tab-content">
                    <div id="prelim" class="container tab-pane active"><br>
                        <div class="row">
                            <div class="form-inline form-padding">
                                <div class="col-sm">
                                    <label>Date:</label>
                                </div>
                                <div class="col-sm">                          
                                    <input type ="date" id="todays-date" value="" class="form-control" name="date" required>

                                </div>
                            </div>
                        </div>
                        <br />
                        <div class="table-responsive">
                            <table id="dtable" class="table table-striped table-hover table-bordered">
                                <thead class="bg-dark text-light">
                                    <tr>
                                        <th class="text-center">Student ID</th>
                                        <th class="text-center">Student Name</th>
                                        <th class="text-center">Status</th>
                                    </tr>
                                </thead>
                                <tbody>
                                <?php while($row = mysqli_fetch_array($rss)): ?>
                                <?php
                                    $studid = $row['student_id'];
                                    $stud = mysqli_query($mysqli,"select * from tbl_student where stud_id = '$studid'");
                                    $rs= mysqli_fetch_array($stud);  
                                ?>
                                    <tr>
                                        <td class="text-center"><?php echo $studid; ?></td>
                                        <td><?php echo $rs['stud_lname'];?>, <?php echo $rs['stud_fname'];?> <?php echo $rs['stud_mname'];?> <?php echo $rs['stud_suffix'];?></td>
                                        <td class="text-center">
                                            <a Title="Present" href='' onclick="this.href='action/actionclass.php?present&classid=<?php echo $classid; ?>&studid=<?php echo $studid;?>&period=Prelim&date='+document.getElementById('todays-date').value"><i class="fas fa-check fa-2x text-success"></i></a>&nbsp;
                                            <a Title="Absent" href='' onclick="this.href='action/actionclass.php?absent&classid=<?php echo $classid; ?>&studid=<?php echo $studid;?>&period=Prelim&date='+document.getElementById('todays-date').value"><i class="fas fa-times fa-2x text-danger"></i></a>
                                        </td>
                                    </tr>
                                    <?php $c++; ?>
                                    <?php endwhile; ?>
                                    <?php if(mysqli_num_rows($rss) < 1): ?>
                                    <tr>
                                        <td colspan="3" class="text-center text-danger"><h5>*** EMPTY ***</h5></td>
                                    </tr>
                                    <?php endif;?>
                                </tbody>
                            </table>
                        </div>
                    </div>

此部分开始第二个标签内容。

                    <div id="midterm" class="container tab-pane fade"><br>
                        <div class="row">
                            <div class="form-inline form-padding">
                                <div class="col-sm">
                                    <label>Date:</label>
                                </div>
                                <div class="col-sm">                          
                                    <input type ="date" id="todays-date" value="" class="form-control" name="date" required>

                                </div>
                            </div>
                        </div>
                        <br />
                        <div class="table-responsive">
                            <table id="dtable" class="table table-striped table-hover table-bordered">
                                <thead class="bg-dark text-light">
                                    <tr>
                                        <th class="text-center">Student ID</th>
                                        <th class="text-center">Student Name</th>
                                        <th class="text-center">Status</th>
                                    </tr>
                                </thead>
                                <tbody>
                                <?php while($row = mysqli_fetch_array($rss)): ?>
                                <?php
                                    $studid = $row['student_id'];
                                    $stud = mysqli_query($mysqli,"select * from tbl_student where stud_id = '$studid'");
                                    $rs= mysqli_fetch_array($stud);  
                                ?>
                                    <tr>
                                        <td class="text-center"><?php echo $studid; ?></td>
                                        <td><?php echo $rs['stud_lname'];?>, <?php echo $rs['stud_fname'];?> <?php echo $rs['stud_mname'];?> <?php echo $rs['stud_suffix'];?></td>
                                        <td class="text-center">
                                            <a Title="Present" href='' onclick="this.href='action/actionclass.php?present&classid=<?php echo $classid; ?>&studid=<?php echo $studid;?>&period=Midterm&date='+document.getElementById('todays-date').value"><i class="fas fa-check fa-2x text-success"></i></a>&nbsp;
                                            <a Title="Absent" href='' onclick="this.href='action/actionclass.php?absent&classid=<?php echo $classid; ?>&studid=<?php echo $studid;?>&period=Midterm&date='+document.getElementById('todays-date').value"><i class="fas fa-times fa-2x text-danger"></i></a>
                                        </td>
                                    </tr>
                                    <?php $c++; ?>
                                    <?php endwhile; ?>
                                    <?php if(mysqli_num_rows($rss) < 1): ?>
                                    <tr>
                                        <td colspan="3" class="text-center text-danger"><h5>*** EMPTY ***</h5></td>
                                    </tr>
                                    <?php endif;?>
                                </tbody>
                            </table>
                        </div>
                    </div>
</div>
</div>
</div>

当您执行 while($row = mysqli_fetch_array($rss)) 时,它将循环直到没有更多的行可以获取。

然后当您再次执行 while($row = mysqli_fetch_array($rss)) 时,它将循环直到没有更多的行可以获取,但是从上次停止的地方(在最后一行之后)开始。

如果那是你应该能够添加的问题

mysqli_data_seek($rss, 0);

就在第二个 while 循环的上方,告诉它再次从第一行重新开始。