title: Display month wise report in php
body: <p>I'm working on a web based application which tracks the daily activities of employees. I've made forms in php in which they enter their details. Also there is an option in which they can diplay the report.</p>
  
  <p>Here is what I've done so far.</p>
  
  <pre><code>&lt;?php
  
  $serverName = "";
  $connectionInfo = array("Database" =&gt; "...", "UID" =&gt;"...", "PWD"=&gt;"..." );
  $conn = sqlsrv_connect($serverName, $connectionInfo);
  if ($conn === false){
      die(print_r(sqlsrv_errors(),true));
  }
  
  $$sql = "(Select Ad.[Act] 'Act', Ad.[Units] 'Units', Ad_Acts.[Name] from Ad JOIN Ad_Act ON Ad.ActID = Ad_Act.ActAttend)
          Union ALL(Select Citi.[Act2] 'Act', Citi.[Units2] 'Units', Citi_act.[Name] from Citi JOIN Citi_Acts ON Citi.ActID2 = Citi_Act.ActAttend2)
           Union ALL(Select ComOut.[Act3] 'Act', ComOut.[Units3] 'Units', ComOut_Act.[Name] from ComOut JOIN ComOut_Act ON ComOut.ActID3 = ComOut_Act.ActAttend3)
           Union ALL(Select ReSchAct.[Act4] 'Act', ReSchAct.[Units4] 'Units', ReSch_Act.[Name] from ReSchAct JOIN ReSch_Act ON ReSchAct.ActID4 = ReSch_Act.ActAttend4)
            Union ALL(Select TeEd.[Act5] 'Act', TeEd.[Units5] 'Units', TeEd_Act.[Name] from TeEd JOIN TeEd_Act ON TeEd.ActID5 = TeEd_Act.ActAttend5)";
  
  
  $totalUnits = 0;
  ?&gt;
  
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;Act&lt;/th&gt;
          &lt;th&gt;Units&lt;/th&gt;
          &lt;th&gt;Name&lt;/th&gt;
      &lt;/tr&gt;
  &lt;?php while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) : ?&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;?php echo $row['Act']&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['Units']&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $row['Name']&lt;/td&gt;
      &lt;/tr&gt;
      &lt;?php $totalUnits = $totalUnits + intval($row['Units']); ?&gt;
  &lt;?php endwhile; ?&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;Total Units: &lt;/td&gt;
          &lt;td&gt;&lt;?php echo $totalUnits; ?&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Now I want to make something such that the user could display the month wise report. The user should have option of selecting the month and view the report.</p>
  
  <p>The above code takes data from different tables of the database. Displays the sum of Units(i.e the total score the user has earned so far). The above code is working now i've to display it month wise.</p>