Zkuste něco v tomto smyslu. Pouze vodítko, skutečná realizace je na vás. Také bych vám doporučil použít {}
spíše než endwhile
.
<?php
$last_row = $mysqli_fetch_array($search_result));
while($row = mysqli_fetch_array($search_result)){
//this is pseudocode, you will need to convert to date objects
$timediff = $last_row['StateStarttime'] - $row['StateEndtime'];
?>
<tr>
<td align="Center"><?php echo $row['id'];?></td>
<td align="Center"><?php echo $row['EmpID'];?></td>
<td align="Center"><?php echo $row['Date'];?></td>
<td align="Center"><?php echo $row['Username'];?></td>
<td align="Center"><?php echo $row['Computername'];?></td>
<td align="Center"><?php echo $row['State'];?></td>
<td align="Center"><?php echo $row['MinutesatState'];?></td>
<td align="Center"><?php echo $row['StateStarttime'];?></td>
<td align="Center"><?php echo $row['StateEndtime'];?></td>
<td align="Center"><?php echo $row['Timestamp'];?></td>
// echo $timediff
</tr>
<?php
$last_row = $row;
}?>