Código PHP:
Adjunto imagen:Ver original
<?php $p=false; $comprobar=""; $i=0; $j=0; $p=0; $cont=0; { $items2[$row[item]][$row[cod_experto]]= $row[cod_color]; } else{ $items2[$row[item]][$row[cod_experto]]=$row[cod_color]; } if($comprobar==$row[item]) $p=true; else { $comprobar=$row[item]; $p=false; $i++; } if($p==false){ $items[$i]=$row[item]; } $experto[$j]=$row[cod_experto]; $valores[$j]=$row[cod_color]; $j++; } echo "<table id='orden_columnas' border> <thead> <tr> <th>ITEM</th>"; foreach ($items2 as $e=>$ex) { foreach($ex as $llave=>$valor){ echo "<th>$llave</th>"; } break; } echo "<th>Ordenar</th>"; echo "</tr>"; echo "</thead>"; echo "<tbody>"; foreach ($items2 as $it=>$vlr_items) { echo "<tr>"; echo "<td bgcolor=#F2F5A9>$it</td>"; $suma_filas = 0; foreach ($vlr_items as $va=>$valores_vect) { echo "<td>$valores_vect</td>"; $suma_filas =$suma_filas+$valores_vect; $totaldecolumna[$valores_vect]=$totaldecolumna[$valores_vect]+$valores_vect; }//cierra foreach valores echo "<td>$suma_filas</td>"; echo "</tr>"; }//cierra foreach items echo "<tr>"; echo "<td>Suma Columnas</td>"; foreach ($vlr_items as $va=>$valores_vect) { echo "<td>$totaldecolumna[$valores_vect]</td>"; } echo "</tr>"; echo "</tbody>"; echo "</table>"; ?>
http://subefotos.com/ver/?15d0049bcb...be1ca82afo.jpg