title: Dynamicaly create table based on the column value
body: <p>I want to create another table if the value of <strong>Semester</strong> and <strong>School Year</strong> is different from the current table.</p>
  
  <p>From the picture below, There was a value of "2 semester" and "school year 2014" basically what i want is each semester and school year has an own table. I don't want to code multiple table because i'm not sure what is the current school year and semester.
  <a href="https://i.stack.imgur.com/PgU39.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PgU39.png" alt="enter image description here"></a></p>
  
  <p>here is my code</p>
  
  <pre><code>&lt;div class="table-responsive"&gt;
  &lt;table class="table table-bordered"&gt;
  
    &lt;thead&gt;
  
      &lt;tr&gt;
        &lt;th&gt;Subject Code&lt;/th&gt;
        &lt;th&gt;Decription&lt;/th&gt;
        &lt;th&gt;Grade&lt;/th&gt;
        &lt;th&gt;Units&lt;/th&gt;
         &lt;th&gt;Semester&lt;/th&gt;
          &lt;th&gt;School Year&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
     &lt;?php
     $sql ="SELECT * FROM grades WHERE stud_no ='$stud_no'";
     $result = mysqli_query($con, $sql);
    while($row = mysqli_fetch_array($result)){                   
    ?&gt;
  
      &lt;tr&gt;
        &lt;td&gt;&lt;?php echo $row['subj_cd'];?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo ucwords(strtolower($row['subj_descr']));?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $row['final_grade'];?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $row['units_lec'] + $row['units_lab'];?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $row['semester'];?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $row['sch_year'];?&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
    &lt;/tbody&gt;
  &lt;?php
  }
  ?&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>