Scusa ho spiegato male io.

Io intendevo una cosa del genere

Codice PHP:
<?php
        
        
include "config.php";
        
connettiDb();
        
        
$sql="select * from maestri where sesso='uomo'";
                 
$dati=mysql_query($sql);
                 
$rows=mysql_fetch_array($dati)
        
                foreach (
$rows as $row) { 
  
$query "SELECT SUM(lezioni.lez) AS totLez tot FROM lezioni WHERE id_ins = " $row['id'] . " AND sesso = 1"
 
        echo 
'  <td style="vertical-align: top;">' trim($row['nome'] . ' ' $row['cognome']) . '

                  </td>
                  <td style="vertical-align: top;">' 
trim($row['scuola'] ) . '

                  </td>
                  <td style="vertical-align: top;">DA INSERIRE
'
;
                  }
?>
Questo era quello che avevo pensato di fare per scrivere un array che prenda automaticamente i vari record dal database. però mi rilascia questo errore:

codice:
Parse error: syntax error, unexpected T_FOREACH