Salve a tutti, sono nuovo del forum e sono subito a chiedervi aiuto.
Ho una pagina in cui genero una tabella con delle input per modificare i dati e rispedire tutto al db.
Questo è il codice della pagina:
Fin qui tutto bene, funziona! Ora però dovrei raccogliere i dati dalla variabile $_POST con la generazione di variabili in automatico ma non so come trattare il seguente ciclo:codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Aggiornamento lista 1</title> </head> <body> <form name="agglista1" action="inslista1.php" method="POST"> <?php require "config.php"; require "connect.php"; $query = "SELECT candidato, seggio1, seggio2, seggio3, seggio4, seggio5, seggio6 FROM lista1 ORDER BY `id_candidato`"; $result= mysql_query($query); if (!$result) { die("Errore nella query $query: " . mysql_error()); } echo ' <table border = "1"> <tr> <th>Candidati</th> <th width=10>Seggio 1</th> <th width=10>Seggio 2</th> <th width=10>Seggio 3</th> <th width=10>Seggio 4</th> <th width=10>Seggio 5</th> <th width=10>Seggio 6</th> </tr>'; $i=0; while ($row = mysql_fetch_array($result)) { $i=$i+1; $candidato = $row['candidato']; $seggio1 = $row['seggio1']; $seggio2 = $row['seggio2']; $seggio3 = $row['seggio3']; $seggio4 = $row['seggio4']; $seggio5 = $row['seggio5']; $seggio6 = $row['seggio6']; echo "<tr> <td>$candidato</td> <td><input type=text size=8 name=seggio1$i value=$seggio1></td> <td><input type=text size=8 name=seggio2$i value=$seggio2></td> <td><input type=text size=8 name=seggio3$i value=$seggio3></td> <td><input type=text size=8 name=seggio4$i value=$seggio4></td> <td><input type=text size=8 name=seggio5$i value=$seggio5></td> <td><input type=text size=8 name=seggio6$i value=$seggio6></td> </tr>"; } echo '</table>'; mysql_free_result($result); mysql_close(); ?> <input type="submit" name="aggiorna" value="Aggiorna"> </form> </body> </html>
Grazie in anticipo!codice:<?php $i=0; while ($_POST) "COME DEVO COMPORTARMI QUI?" { $i=$i+1; $seggio1$i = $_POST['seggio1$i']; $seggio2$i = $_POST['seggio2$i']; $seggio3$i = $_POST['seggio3$i']; $seggio4$i = $_POST['seggio4$i']; $seggio5$i = $_POST['seggio5$i']; $seggio6$i = $_POST['seggio6$i']; } ?>

Rispondi quotando