Jump to content

how to make radio button checked php in table dynamique


ab2Info

Recommended Posts

hi,

i want to make radio button checked php in table dynamique 

the problem is when i check the radio button in second rows , the first rows Loses value , 

The same thing occurs with rows
 
--------------------------------------------
 
<body>
 
<h2 align="center">Feuille de Présence Seminaire 1</h2>
<div style="overflow-x:auto;">
  <table>
    <tr>
      <th>Cin</th>
      <th>Nom</th>
      <th>Prenom</th>
      <th>Spécilité</th>
      <th>Le Mois 1</th>
      <th>Le Mois 2</th>
      <th>Le Mois 3</th>
      
 
 
    </tr>
    <?php while($pre=mysqli_fetch_assoc($res)) {?>
    <tr>
      <td><?php echo($pre['cin'])?></td>
      <td><?php echo($pre['nom'])?></td>
      <td><?php echo($pre['prenom'])?></td>
      <td><?php echo($pre['specialite'])?></td>
     <!--Mercredi 04 janvier -->
      <td>
<select name="specialite3">
<option value="matin" <?php if ($pre['specialite']=='matin') {
echo 'selected';}?>/>matin</option>
<option value="Après Midi" <?php if ($pre['specialite']=='Après Midi') {echo 'selected';}?>/>Après Midi</option>
</select>
<input type="radio" value="Oui" name="gender" <?php if ($pre['specialite']=="Oui") {echo "checked";}?>/>Oui
<input type="radio" value="Non" name="gender"<?php if ($pre['specialite']=="Non") echo "checked";?>/>Non
</td>
<!--Mercredi 04 janvier -->
<td><select name="specialite3">
<option value="matin" <?php if ($pre['specialite']=='matin') {
echo 'selected';}?>/>matin</option>
<option value="Après Midi" <?php if ($pre['specialite']=='Après Midi') {echo 'selected';}?>/>Après Midi</option>
</select>
 
  </td>
<!--Mercredi 04 janvier -->
<td><select name="specialite3">
<option value="matin" <?php if ($pre['specialite']=='matin') {
echo 'selected';}?>/>matin</option>
<option value="Après Midi" <?php if ($pre['specialite']=='Après Midi') {echo 'selected';}?>/>Après Midi</option>
</select></td>
    </tr>
 <?php }?>
  </table>
 <div align="center"> <button class="button"><span>Enregistrer </span></button></div>
</div>
 
</body>
Link to comment
Share on other sites

To maintain the selection for each person, you need to use unique values for the name attributes in the <input> tag. For example

<label><input type="radio" value="Oui" name="gender1" <?php if ($pre['specialite']=="Oui") {echo "checked";}?>/>Oui</label>
<label><input type="radio" value="Non" name="gender1"<?php if ($pre['specialite']=="Non") echo "checked";?>/>Non</label>
 
...
 
<label><input type="radio" value="Oui" name="gender2" <?php if ($pre['specialite']=="Oui") {echo "checked";}?>/>Oui</label>
<label><input type="radio" value="Non" name="gender2"<?php if ($pre['specialite']=="Non") echo "checked";?>/>Non</label>
 
Note the "gender1" and "gender2" values.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.