in un db ho due tabelle chiamate schede e domande.
la tabella schede è strutturata così:
id_scheda, nome, stato
la tabella domande è strutturata così:
id_quiz, idscheda, domanda, ra, rb,rc
Riseco ad inserire sia record nella tabella schede che nella tabella domande e pure a cancellarli.
Riesco a modificare i record di schede mentre non riesco a modificare i record della tabella di domande seppure i due script sono simili.
In pratica eseguo una query per listare i componenti di schede e poi ho aggiunto per ogni record un pulsante modifica che mi porta alla pagina mod_scheda.php e poi ho anche un link "domande" che mi fa l'elenco delle domande riferite ad ogni scheda.
query di lista_schede.php
	Codice PHP:
	
$result = mysql_query("SELECT * FROM schede") 
or die(mysql_error());
echo "<table border='5'>";
echo "<tr> <th>Nome</th> <th>stato</th> <th>---</th> <th>---</th> <th>---</th> <th>---</th></tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
    $id=$row['id_scheda'];
    echo "<tr><td>".$row['nome']."</td><td>".$row['stato']."</td>";
     echo "<td><a href=\"listadom.php?mod=$id\">[domande]</a></td>";
    echo"<td><a href=\"canc.php?del=$id\" onclick=\"return(confirm('stai eliminando ".$row['nome']."'))\" >[cancella]</a></td>";
    echo "<td><a href=\"mod_scheda.php?mod=$id\">[modifica]</a></td>";
} 
echo "</table>";
?> 
 
Questo è la pagina per modificare le schede:
mod_scheda.php
	Codice PHP:
	
<?php
if(isset($_POST['modifica'])){//se hai premuto il submit del form modifica 
    $id=$_POST['id'];
    $nome=$_POST['nome'];
    $q="UPDATE schede SET nome='$nome' WHERE id_scheda='$id'"; 
    $ris=mysql_query($q); 
    echo "aggiornato il record $id"; 
    echo "<meta http-equiv='Refresh' content='3; URL=listaschede.php'>";
    }
//*********** 
if(isset($_GET['mod'])){//hai cliccato su MODIFICA della pagina listaschede.php
    $id=addslashes(htmlspecialchars($_GET['mod']));
    $q="SELECT * FROM schede  WHERE id_scheda='$id'"; 
    $ris=mysql_query($q); 
    $riga=mysql_fetch_array($ris);
    $nome=$riga['nome'];
?> 
<!-- form modifica -->
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" name="modifica"> 
  <p>
    <input name="id" type="hidden" id="id" value="<?php echo $id;?>">
    <br> Aggiugi scheda
    <input name="nome" type="text" id="nome" value="<?php echo $nome;?>">
  </p> 
  <p> 
    <input name="modifica" type="submit" id="modifica" value="modifica"> 
</p> 
</form>
<?php
}else{
    //echo "i get non funziano";//**** avviso che i get non vengole trasmessi o letti 
    echo "<meta http-equiv='Refresh' content='0; URL=listaschede.php'>"; 
}
?>
 
Questa è la pagina della lista delle domande
listadom.php
	Codice PHP:
	
    $id_scheda=($_GET['mod']);
    $ris = mysql_query("SELECT * FROM domande  WHERE idscheda='$id_scheda'") ;
    $result = mysql_query("SELECT * FROM schede WHERE id_scheda=$id_scheda") or die(mysql_error());
    $row1 = mysql_fetch_array( $result);
     echo "Elenco domande della scheda ".$row1['nome'];
echo '<table width="50%" border="1" cellspacing="1" cellpadding="3">';
echo "<tr> <th>Id</th> <th>Idscheda</th> <th>domanda</th> <th> Risposta A</th> <th> Risposta B </th><<th> Risposta C </th><th> Risposta D </th><th> </th><th> </th>  </tr>";
    while($row = mysql_fetch_array( $ris )) {
        $id_quiz=$row['id_quiz'];
        echo "<tr><td>".$row['id_quiz']."</td><td>".$row['idscheda']."</td><td>".$row['domanda']."</td><td>".$row['ra']."</td><td>".$row['rb']."</td><td>".$row['rc']."</td><td>".$row['rd']."</td>";
    echo "<td><a href=\"mod_dom.php?mod=$id_quiz\">[mod]</a></td>";
    echo"<td><a href=\"mod_dom.php?del=$id_quiz\" onclick=\"return(confirm('stai eliminando la domanda'))\" >[del]</a></td></tr>";
    } 
echo "</table>"; 
 
Fin qui nessun problema.
Ho il problema nel file mod_dom.php dove devo modificare i record della tabella domande.
mod_dom.php
	Codice PHP:
	
<?php
if(isset($_POST['modifica'])){//se hai premuto il submit del form modifica 
    $id=$_POST['id'];
    $domanda=$_POST['domanda'];
    $ra=$_POST['ra'];
    $rb=$_POST['rb'];
    $rc=$_POST['rc'];
    $rd=$_POST['rd'];
    $q="UPDATE domande SET domanda='$domanda', ra='$ra', rb='$rb', rc='$rc', rd='$rd', WHERE id_quiz='$id'"; 
    $ris=mysql_query($q); 
    echo "aggiornato il record $id";
    echo "<meta http-equiv='Refresh' content='3; URL=listadom?mod=$id.php'>";
    }
if(isset($_GET['mod'])){//hai cliccato su MODIFICA della pagina precedente dell'elenco
    $id=addslashes(htmlspecialchars($_GET['mod']));
    $q="SELECT * FROM domande  WHERE id_quiz='$id'"; 
    $ris=mysql_query($q); 
    $riga=mysql_fetch_array($ris);
    //$id_quiz=$riga['id_quiz'];
    $domanda=$riga['domanda'];
    $ra=$riga['ra'];
    $rb=$riga['rb'];
    $rc=$riga['rc'];  
    $rd=$riga['rd'];
?> 
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" name="modifica"> 
<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
    <tr>
    <input name="id" type="hidden" id="id" value="<?php echo $id;?>">
      <th>Domanda </th>
      <td>
        <textarea name="domanda" id="domanda" rows=4 cols=25 class='text_area'><?php echo $domanda;?></textarea>
      </td>
    </tr>
    <tr>
      <th>A
      </th>
      <td>
      <input name="ra" type="text" class="textfield" id="ra" value="<?php echo $ra;?>"/>
          </td>
    </tr>
    <tr>
      <th>B</th>
      <td><input name="rb" type="text" class="textfield" id="rb" value="<?php echo $rb;?>"/></td>
    </tr>
    <tr>
      <th>C</th>
      <td><input name="rc" type="text" class="textfield" id="rc" value="<?php echo $rc;?>"/></td>
    </tr>
    <tr>
      <th>D</th>
      <td><input name="rd" type="text" class="textfield" id="rd" value="<?php echo $rd;?>"/></td>
    </tr>
    <tr>
      <td> </td>
      <td><input type="submit" name="Submit" value="modifica" /></td>
    </tr>
  </table>
</form>
<?php
}else{
    //echo "i get non funziano";//**** avviso che i get non vengole trasmessi o letti 
    //se accedi direttamente a questa pagina viene riportato subito alla stampa_eventi.php
    echo "<meta http-equiv='Refresh' content='0; URL=listaschede.php'>"; 
}
?>
 
Seppure mi carica la pagina mod_dom.php quando clicco sul submit Modifica nel db non mi aggiorna le modifiche fatte. Mentre funziona tutto regolamente per la tabella schede.
Dove sbaglio?