Codice PHP:
<tbody>
                    <?php
                    
foreach ($queryPacc as $var):
                        
$upNow $var['uscita_pacc'];

                        if (isset(
$upOld) && $upNow != $upOld):
                            
?>
                            <tr>
                                <th>TOT <?php echo $upOld?></th>
                                <th></th>
                                <th></th>
                                <th></th>
                                <th></th>
                            </tr>
                        <?php endif; ?>

                        <tr>                         
                             <td></td>
                             <td></td>
                             <td></td>
                             <td></td>
                             <td></td>
                        </tr>
                        <?php
                        $upOld 
$var['uscita_pacc'];
                    endforeach;
                    
?>

                            <tr>
                                <th>TOT <?php echo $upOld?></th>
                                <th></th>
                                <th></th>
                                <th></th>
                                <th></th>
                            </tr>                    
                            <tr>
                        <th>TOTALE</th>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th></th>
                    </tr>
                </tbody>