secondo me., e mi ripeto è proprio sbagliata la struttura del db cmq puoi fare una cosa del genere
Codice PHP:
<table>
<tr>
<td></td>
<td>tab_a</td>
<td>tab_b</td>
<td>tab_c</td>
<td>altro</td>
<?php
$sql
="select id_cond, causale, sum(crediti) as crediti, sum(debiti) as debiti from contocond group by id_cond, causale";
$result mysql_query($sql);
$i=0;
while(
$row mysql_fetch_array($result))
  {
       
$id=$row['id_cond'];
       
$resto=$i%5;
        if (
$resto==0)
        {
               echo 
"</tr>";
               echo 
"<tr>";
               echo 
"<td>".$row['id_cond']."</td>";
        }
        if(
$resto==4)
        {
              echo 
"<td>".$row['debiti']."</td>";
        }
        else
        {
             echo 
"<td>".$row['crediti']."</td>";
        }
        
$i++;
  }
?>
</tr>
</table>