1
我想第一學期S.Y 2013只顯示一次。但在我的代碼中,它顯示多次,因爲它在循環內部。有沒有其他方法可以做到這一點?如何在循環內只顯示一次提取的數據
這裏的循環
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Subject Code</th>
<th>Decription</th>
<th>Grade</th>
<th>Units</th>
</tr>
</thead>
<tbody>
<?php
$sql ="SELECT * FROM grades WHERE stud_no ='$stud_no'";
$result = mysqli_query($con, $sql);
while($row = mysqli_fetch_array($result)){
?>
<tr>
<td></td>
<td><?php echo $row['semester']. "st Semester S.Y " .$row['sch_year'];?></td>
<td></td>
<td></td>
</tr>
<tr>
<td><?php echo $row['subj_cd'];?></td>
<td><?php echo $row['subj_descr'];?></td>
<td><?php echo $row['final_grade'];?></td>
<td><?php echo $row['units_lec'] + $row['units_lab'];?></td>
</tr>
</tbody>
<?php
}
?>
</table>
</div>