Php 如何在循环中只显示一次获取的数据
我希望仅显示一次2013年第一学期的。但在我的代码中,它会显示多次,因为它在循环中。有没有别的办法 这是我的代码的输出。 这是循环Php 如何在循环中只显示一次获取的数据,php,html,sql,Php,Html,Sql,我希望仅显示一次2013年第一学期的。但在我的代码中,它会显示多次,因为它在循环中。有没有别的办法 这是我的代码的输出。 这是循环 <div class="table-responsive"> <table class="table table-bordered"> <thead> <tr> <th>Subject Code</th> <th>Decription<
<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>
主题代码
描述
等级
单位
<?php
$sql ="SELECT * FROM grades WHERE stud_no ='$stud_no'";
$result = mysqli_query($con, $sql);
var $check=1; //added line
while($row = mysqli_fetch_array($result)){
?>
<td><?php
if($check==1){
echo $row['semester']. "st Semester S.Y " .$row['sch_year'];
$check=0;
}
?></td>