grazie mille per l'attenzione, adesso ho fatto cosi:
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)){ if($xn <= $nm){ $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>'; }else{ $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; }
queste sono le tabelle
midaresti una mano....codice:-- -- Struttura della tabella `cat_staff` -- CREATE TABLE `cat_staff` ( `id` int(11) NOT NULL auto_increment, `categoria` varchar(100) NOT NULL default '', `posizione` int(11) NOT NULL default '0', PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=6 ; -- -- Dump dei dati per la tabella `cat_staff` -- INSERT INTO `cat_staff` VALUES (1, 'Direzione', 1); INSERT INTO `cat_staff` VALUES (2, 'Amministrazione', 2); INSERT INTO `cat_staff` VALUES (3, 'Estero', 3); INSERT INTO `cat_staff` VALUES (4, 'Arredatori', 4); INSERT INTO `cat_staff` VALUES (5, 'Assistenza', 5); -- -------------------------------------------------------- -- -- Struttura della tabella `staff` -- CREATE TABLE `staff` ( `id` int(11) NOT NULL auto_increment, `id_staff` int(11) NOT NULL default '0', `foto` varchar(255) NOT NULL default '', `descrizione` text NOT NULL, PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=17 ; -- -- Dump dei dati per la tabella `staff` -- INSERT INTO `staff` VALUES (1, 1, 'direzione.jpg', 'STAFF 1'); INSERT INTO `staff` VALUES (2, 2, 'direzione.jpg', 'STAFF 2'); INSERT INTO `staff` VALUES (5, 2, 'direzione.jpg', 'STAFF 2'); INSERT INTO `staff` VALUES (4, 2, 'direzione.jpg', 'STAFF 2'); INSERT INTO `staff` VALUES (6, 2, 'direzione.jpg', 'STAFF 2'); INSERT INTO `staff` VALUES (7, 3, 'direzione.jpg', 'STAFF 3'); INSERT INTO `staff` VALUES (8, 3, 'direzione.jpg', 'STAFF 3'); INSERT INTO `staff` VALUES (9, 3, 'direzione.jpg', 'STAFF 3'); INSERT INTO `staff` VALUES (10, 4, 'direzione.jpg', 'STAFF 4'); INSERT INTO `staff` VALUES (11, 4, 'direzione.jpg', 'STAFF 4'); INSERT INTO `staff` VALUES (12, 4, 'direzione.jpg', 'STAFF 4'); INSERT INTO `staff` VALUES (13, 5, 'direzione.jpg', 'STAFF 4'); INSERT INTO `staff` VALUES (14, 5, 'direzione.jpg', 'STAFF 5'); INSERT INTO `staff` VALUES (15, 5, 'direzione.jpg', 'STAFF 5'); INSERT INTO `staff` VALUES (16, 5, 'direzione.jpg', 'STAFF 5');![]()
grazie![]()