le tabelle sono:

a_corsi = id_corsi, nome_corso
a_materie = id_materie, nome_materia
a_corsi_materie = id_corsi, id_materie

e il codice è questo:

Codice PHP:
<form enctype="multipart/form-data" name="form" action="<?=$PHP_SELF?>" method="post">
<table width="650" border="0" cellspacing="0" cellpadding="0">
      <tr>
    <td width="113" height="33"><span class="testo_grigio_bold">nome corso </span></td>
    <td width="162" align="right"><input name="nome_corso" type="text" size="18" maxlength="30"></td>
    <td width="100"></td>
    <td width="275"><input type="hidden" name="pagina" value="1">
          <input name="submit" type="submit" class="pulsante" value="inserisci">
<?
    
if ($msg){?>
      <span class="testo_viola_bold">
      <?=$msg?>
      </span>
      <?
        
}?>
</td>
    </tr>
<tr>
    <td height="1" colspan="4" valign="top" bgcolor="BF9BB5"></td>
    </tr>
      <tr>
        <td height="41" colspan="2"><span class="testo_viola_bold">elenco materie</span></td>
        <td></td>
    <td></td>
    </tr>
    </table>
<table width="650" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td height="1" colspan="4" bgcolor="BF9BB5"></td>
    </tr>
    
    
    
                              <?
                          $i
=1;
                        
$sql mysql_query("SELECT * FROM a_materie ORDER BY nome_materia") or die(mysql_error());
                        while(
$row=mysql_fetch_array($sql)){
                            if (
$i==1){ echo "<tr>";} ?>
              <td height="41" width="216">
<span class="testo_grigio_bold">[img]../images/menu_triangolo.gif[/img]<?=$row['nome_materia']?> <input type="checkbox" name="<?=$row['id_materie']?>" value=""></span>
</td>
                  <?
                            
if ($i==3){
                                echo 
"<td width=\"2\"></td></tr><tr>
    <td height=\"1\" colspan=\"4\" bgcolor=\"BF9BB5\"></td>
    </tr>"
;
                                
$i=0;
                            }
                             
$i++;
                        }
?>
                          </table>
<table width="650" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td height="1" colspan="4" bgcolor="BF9BB5"></td>
    </tr>
    <tr>
    <td height="41" colspan="4" ><span class="testo_viola_bold">elenco corsi</span></td>
    </tr>
    <tr>
    <td height="1" colspan="4" bgcolor="BF9BB5"></td>
    </tr>
                              <?
                          $i
=1;
                        
$sql mysql_query("SELECT * FROM a_corsi ORDER BY nome_corso") or die(mysql_error());
                        while(
$row=mysql_fetch_array($sql)){
                            if (
$i==1){ echo "<tr>";} ?>
              <td height="41" width="216">
<span class="testo_grigio_bold"><a href="<?=$PHP_SELF?>?corso=<?=$row[id_corsi]?>&pagina=2">[img]../images/menu_triangolo.gif[/img]
      <?=$row['nome_corso']?></a></span>
</td>
                  <?
                            
if ($i==3){
                                echo 
"<td width=\"2\"></td></tr><tr>
    <td height=\"1\" colspan=\"4\" bgcolor=\"BF9BB5\"></td>
    </tr>"
;
                                
$i=0;
                            }
                             
$i++;
                        }
?>
                          </table></form>