title: How to echo Month wise data in PHP MySqli?
body: <p>I have a simple question, How to echo month wise data? Each month has commonly 2-3 head of fees. Eg, Tution fees + Semester fees + Activity fees.</p>
  
  <p>I want to echo all stored value in April, July, Aug...and so inside <code>&lt;table&gt;&lt;/table&gt;</code>. For that I am using two While loops, First is for selecting month and class, Second loop which is inside first loop, for printing value inside the selected month. But loop is printing same top value multiple times. </p>
  
  <p>Eg, Apr has 3 heads, and in database table Tution fees is on top, now the loop is printing Tution fees 3 times.</p>
  
  <p>Kindly help me with this.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>&lt;table  class="table table-bordered responsive"&gt;
  &lt;tr&gt;
  &lt;th colspan="2"&gt;
  Fees Detail&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;th&gt;Fee Name&lt;/th&gt;
  &lt;th&gt;Amount&lt;/th&gt;
  &lt;th&gt;Status&lt;/th&gt;
  &lt;/tr&gt;
  &lt;?php
  $data = mysqli_query($conn,"SELECT * FROM fees_on_class WHERE class = '$qry[class]' GROUP BY month_id ");
  while($row = mysqli_fetch_array($data)) 
  {
  
  echo "&lt;tr&gt;";
  echo "&lt;th colspan='3'&gt;"."&lt;input type='checkbox' id='selectall'/&gt;". "Month:- ".$row['month']."&lt;/th&gt;";
  echo "&lt;/tr&gt;";
  
  $d = mysqli_query($conn,"SELECT * FROM fees_on_class WHERE month = '$row[month]' AND class = '$row[class]' ");
  while($r = mysqli_fetch_array($d)) 
  {
  echo "&lt;tr&gt;";
  echo "&lt;td&gt;"."&lt;input type='checkbox' class='case' name='case' value='1'/&gt;".$row['fees_head']."&lt;/td&gt;";
  echo "&lt;td&gt;".$row['amount'];"&lt;/td&gt;";
  echo "&lt;td&gt;"."status"."&lt;/td&gt;";
  echo "&lt;/tr&gt;";
  }
  }
  ?&gt;
  &lt;/table&gt;
  </code></pre>