Bouton de type radio.
Résolu
phpuser
Messages postés
64
Statut
Membre
-
phpuser Messages postés 64 Statut Membre -
phpuser Messages postés 64 Statut Membre -
Bonsoir,
j'ai créer une table de commande dont la dernière colonne(commandes_réservées)contient un bouton type radio,permettant à l'administrateur de spécifier si une commandes sera reservée ou pas.
bref,mon problème c'est que je ne peux cocher qu'une seule commande dans toute la table.SVP,pourriez vous me dire comment cocher plusieurs boutons(type radio) à la fois,
merci bien pour votre aide précieuse .
voici la partie concernée du code PHP :
<table width="600" border="1" cellspacing="0" cellpadding="5">
<tr>
<td>id_commande</td>
<td>designation</td>
<td>utilite</td>
<td>nom_commande</td>
<td>date_commande</td>
<td>id_user</td>
<td>commandes_reservées</td>
</tr>
<?php $i=4;
while($article2=mysql_fetch_array($resultat2)) {
$i++;
?>
<tr>
<td><?php echo $article2['id_commande']; ?></td>
<td><?php echo $article2['designation']; ?></td>
<td><?php echo $article2['utilite']; ?></td>
<td><?php echo $article2['type_materiel']; ?></td>
<td><?php echo $article2['date_commande']; ?></td>
<td><?php echo $article2['id_user']; ?></td>
<td> oui : <INPUT type=radio name="bouton<?php $i;?>" value="y">
non : <INPUT type=radio name="bouton<?php $i;?>" value="n"> </td>
</tr>
<?php }?>
<label>
<input type="submit" name="bouton4" value="valider" />
</label>
</p>
</table>
<?php } ?>
</form>
j'ai créer une table de commande dont la dernière colonne(commandes_réservées)contient un bouton type radio,permettant à l'administrateur de spécifier si une commandes sera reservée ou pas.
bref,mon problème c'est que je ne peux cocher qu'une seule commande dans toute la table.SVP,pourriez vous me dire comment cocher plusieurs boutons(type radio) à la fois,
merci bien pour votre aide précieuse .
voici la partie concernée du code PHP :
<table width="600" border="1" cellspacing="0" cellpadding="5">
<tr>
<td>id_commande</td>
<td>designation</td>
<td>utilite</td>
<td>nom_commande</td>
<td>date_commande</td>
<td>id_user</td>
<td>commandes_reservées</td>
</tr>
<?php $i=4;
while($article2=mysql_fetch_array($resultat2)) {
$i++;
?>
<tr>
<td><?php echo $article2['id_commande']; ?></td>
<td><?php echo $article2['designation']; ?></td>
<td><?php echo $article2['utilite']; ?></td>
<td><?php echo $article2['type_materiel']; ?></td>
<td><?php echo $article2['date_commande']; ?></td>
<td><?php echo $article2['id_user']; ?></td>
<td> oui : <INPUT type=radio name="bouton<?php $i;?>" value="y">
non : <INPUT type=radio name="bouton<?php $i;?>" value="n"> </td>
</tr>
<?php }?>
<label>
<input type="submit" name="bouton4" value="valider" />
</label>
</p>
</table>
<?php } ?>
</form>
2 réponses
-
Salut !
Il ne faut pas utiliser Radio, il faut utiliser Checkbox !
Edit : Et faut penser à changer le nom des boutons (bouton1, bouton2, etc) pour faciliter la gestion des données.
;)
Musicalement,
DJ Fire-Bl@ck. -
Bonjour,
il faut procéder à l'aide d'un echo et mettre le code de ton tableau entre guillemets comme ci-après :
<table width="600" border="1" cellspacing="0" cellpadding="5">
<tr>
<td>id_commande</td>
<td>designation</td>
<td>utilite</td>
<td>nom_commande</td>
<td>date_commande</td>
<td>id_user</td>
<td>commandes_reservées</td>
</tr>
<?php $i=4;
while($article2=mysql_fetch_array($resultat2)) {
echo '<tr>
<td>'.$article2['id_commande'].'</td>
<td>'.$article2['designation'].'</td>
<td>'.$article2['utilite'].'</td>
<td>'.$article2['type_materiel'].'</td>
<td>'.$article2['date_commande'].'</td>
<td>'.$article2['id_user'].'</td>
<td> oui : <INPUT type=radio name="bouton'.$i.'" value="y">
non : <INPUT type=radio name="bouton'.$i.'" value="n"> </td>
</tr>';
$i++
}
<label>
<input type="submit" name="bouton4" value="valider" />
</label>
</p>
</table>
-
merci infiniment Eastchild pour ton aide précieuse ,j'ai une toute petite question :pour réccupèrer les valeurs des boutons radio j'ai mis :if(isset($_POST['bouton16'])){$j=0;
for($i=4;$i<9;$i++){if(isset($_POST["bouton'.$i.'"])){
if($_POST["bouton'.$i.'"]=="y"){
$j++;
}}
}
echo $j;
} .mais ça ne me donne rien,savez vous pourquoi ??
merci encore. -
-
-