risolto!!!
codice:
function cat_staff($conn){
$query = "SELECT *FROM `cat_staff` ORDER BY `posizione` ASC";
$es = mysql_query($query, $conn) or die(mysql_error());
$totalRows_es = mysql_num_rows($es);
$stampa .='<tr>';
if($totalRows_es > 0){
$divido = $totalRows_es / 2;
$nm = floor($divido);
$xn = 0;
$stampa .= '<td>';
while($row_es = mysql_fetch_assoc($es)){
$stampa .= '<table width="339" border="0" cellspacing="0" cellpadding="0">';
$id = $row_es['id'];
$categoria = $row_es['categoria'];
$posizione = $row_es['posizione'];
$query_staff = "SELECT * FROM `staff` WHERE `id_staff` = '$id'";
$es_staff = mysql_query($query_staff, $conn) or die(mysql_error());
$totalRows_es_staff = mysql_num_rows($es_staff);
if($totalRows_es_staff > 0){
$stampa .= '<tr><td colspan="2" align="right" class="text_aran " style="padding-right:10px">'.$categoria.'</td></tr>
<tr><td colspan="2" align="right" bgcolor="#E67106" class="text_aran " style="padding-right:10px">[img]img/spacer.gif[/img]</td></tr>
<tr><td height="8" colspan="2">[img]img/spacer.gif[/img]</td></tr>';
while($row_es_staff = mysql_fetch_assoc($es_staff)){
$id_staff = $row_es_staff['id'];
$id_posizione = $row_es_staff['id_staff'];
$foto = $row_es_staff['foto'];
$descrizione = $row_es_staff['descrizione'];
$stampa .= '<tr bgcolor="#EEEEEE">
<td width="61" align="center">[img]img/staff/'.$foto.'[/img]</td>
<td style="padding-left:10px">variabile incremento: '.$xn.'
n. colonne: '.$nm.'
ris. totali: '.$totalRows_es.'
Id Staff: '.$id_posizione.'</td></tr>
<tr><td colspan="2"></td>
</tr>';
}; // FINE WHILE
}; // FINE IF
$xn++;
$stampa .= '</table>';
if($xn > $nm){
$stampa .= '</td><td>';
$stampa .= '<table width="339" border="0" cellspacing="0" cellpadding="0">';
$xn = 0;
}; // FINE IF
}; // FINE WHILE
$stampa .= '</td>';
}; // FINE IF
$stampa .='</tr>';
return $stampa;
}
grazie ho riflettuto su quello che mi hai detto!