prova a vedere questo esempio con un solo set di radio buttons,
trovi la gestione del valore letto da db
e la gestione del valore di default, se non viene fatta nessuna scelta perché non impostato dal db
Codice PHP:
<?php$groupRadio1 = null; // valore (1, 2, 3) che può essere letto dal DB,
if(!empty($_POST) and empty($_POST["groupRadio1"])) { $_POST["groupRadio1"] = $_POST["groupRadio1h"]; }
print_r($_POST); echo "<br /><br />";
?><!DOCTYPE html><html> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table border="0"> <tr> <td><input type="radio" name="groupRadio1" value="1" <?= ($groupRadio1 == 1) ? "checked " : ""; ?>/></td> <td>SI</td> </tr> <tr> <td><input type="radio" name="groupRadio1" value="2" <?= ($groupRadio1 == 2) ? "checked " : ""; ?>/></td> <td>NO</td> </tr> <tr> <td><input type="radio" name="groupRadio1" value="3" <?= ($groupRadio1 == 3) ? "checked " : ""; ?>/></td> <td>N/A</td> </tr> </table> <br />
<input type="hidden" value="3" name="groupRadio1h">
<br /> <br /> <input type="submit" value="Submit Form"> </form> </body></html>
se ho capito quello che ti serve, e l'esempio é pertinente puoi adattarlo e gestire gli altri set radio