title: Get the sum of rows in dompdf
body: <p>I have attendance table like the following.
  <a href="https://i.stack.imgur.com/R7NVV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R7NVV.png" alt="enter image description here"></a></p>
  
  <pre><code>ID      date_in     time_in     time_out
   1     2017-05-04   8.10        16.20
   1     2017-05-05   6.10        12.20
   5     2017-05-04   9.30        16.22
   5     2017-05-05   8.20        16.23
   ....
  </code></pre>
  
  <p>I want to get the ot hours per employee for searched month and print the report and i'm using dompdf for reports.My desired output report is : </p>
  
  <pre><code> ID     Name     Total OTHours
   1      John      14.20
   5      Smith     22.20
  </code></pre>
  
  <p>I worked with the following code. But the sum of ot hours not working and the pdf file is not working. Please can someone assist me to find the solution???</p>
  
  <pre><code> $query = "
      SELECT * FROM employee_personal_details e
      INNER JOIN attendance_details a ON e.emp_id = a.emp_id
      WHERE MONTH(a.date_in) = '$monthSearch' 
      GROUP BY e.emp_id ";
  
       $result = mysqli_query($connect, $query);
  
         $output = "
              &lt;table&gt;
                  &lt;tr&gt;
                  &lt;th&gt;ID&lt;/th&gt;
                  &lt;th&gt;Name&lt;/th&gt;
                  &lt;th&gt;Total OT Hours&lt;/th&gt;
                  &lt;/tr&gt;
                 ";
  
  while($row = mysqli_fetch_array($result)){
  
   $output .= '
    &lt;tr&gt;
     &lt;td&gt;'.$row["emp_id"].'&lt;/td&gt;
     &lt;td&gt;'.$row["emp_fullName"].'&lt;/td&gt;';
  
  
    //calculate the time difference 
    $datetime1 = new DateTime($row['time_out']);
    $datetime2 = new DateTime($row['time_in']);
    $interval = $datetime1-&gt;diff($datetime2);
    $workedHours = $interval-&gt;format('%h'.'.'.'%I');
  
      //expected hours 
      $expectedHour=8;
  
      //calculate the ot hours    
      $ot = $workedHours-$expectedHour;
  
      if($ot&gt;0.3){
         $sumot += $ot;
      }
  
  
  $output .= '
     &lt;td&gt;'.$sumot.'&lt;/td&gt;     
    &lt;/tr&gt;
   ';
  }
  
    $output .= '&lt;/table&gt;';
  
   //echo $output;
   $dompdf-&gt;loadHtml($output);
  </code></pre>