Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在循环中只显示一次获取的数据_Php_Html_Sql - Fatal编程技术网

Php 如何在循环中只显示一次获取的数据

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<

我希望仅显示一次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>

主题代码
描述
等级
单位

<?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>