第一个选项卡工作正常,但是当我复制它并粘贴其他选项卡的内容时,它无法正常工作。我有一个显示当前日期的日期输入,但是它也是可编辑的,选项卡内容还包含显示数据的表。当您单击“中期”标签时,它不会在表格内显示数据,而且日期也不会显示我与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>
<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>
<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>
答案 0 :(得分:0)
当您执行while($row = mysqli_fetch_array($rss))
时,它将循环播放,直到没有更多行可以提取为止。
然后,当您再次执行while($row = mysqli_fetch_array($rss))
时,它将循环直到没有其他行可取,而是从上次中断的位置(最后一行之后)开始。
如果是这个问题,您应该可以添加
mysqli_data_seek($rss, 0);
恰好在您的第二个while循环上方,告诉它再次从第一行重新开始。