|
|
|
|
Bonjour,
j'ai cherché en vain une réponse à ma question sur ce forum.
Voilà mon problème :
j'ai un formulaire HTML dans une première page :
<form> <p>Que voulez-vous étudier ? Cocher les cases utiles. <table border="2" cellpadding="5"> <tr><th colspan="2"><input type="checkbox" name="choix[]" value="a"><a href="a.php">A</a></th></tr> <tr><th colspan="2"><input type="checkbox" name="choix[]" value="b"><a href="b.php">B</a></th></tr> <tr><th colspan="2"><input type="checkbox" name="choix[]" value="c"><a href="c.php">C</a></th></tr> <tr><th width="20%" rowspan="6">autre</th> <td width="300"><input type="checkbox" name="choix[]" value="d"> <a href="d.php">D</a></td></tr> <tr><td><input type="checkbox" name="choix[]" value="e"> <a href="e.php">E</a></td></tr> <tr><td><input type="checkbox" name="choix[]" value="f"> <a href="f.php">F</a></td></tr> <tr><td><input type="checkbox" name="choix[]" value="g"> <a href="g.php">G</a></td></tr> <tr><td><input type="checkbox" name="choix[]" value="h"> <a href="h.php">H</a></td></tr> <tr><td><input type="checkbox" name="choix[]" value="i"> <a href="i.php">I</a></td></tr> </table> </div> </form>
<? if(isset($_POST['choix']))
{$_SESSION['choix']=$_POST['choix'];}
else{$_SESSION['choix']=' ';}
echo 'Vous avez choisi d\'étudier : ';
for ($i=0; $i<sizeof($_SESSION['choix']); $i++)
{if ($_SESSION['choix'] == '')
{echo '';}
else
{echo $_SESSION['choix'][$i].'<br>';}
}
?>
if ($_SESSION['choix'][$i] == 'checked')?
Tu es sur la bonne piste pour ce qui est d'utiliser des formulaires avec des tableaux.
for ($ascii = ord('A'); $ascii <= ord('Z'); $ascii++)
{
echo chr($ascii);
}
Ou encore, tu peux appeler tes input name="choix1", et faire une boucle avec : for ($i=0,$i<7,$i++ {
if ($_POST['choix'.$i]) {
echo "choix ".$i; }
}
Sinon, avec un name="choix[]" , tu peux recuperer tes valeur avec : $tab =$_POST['choix']; $tab est alors un array, donc if (isset($tab)) est toujours TRUE. C'est if (isset($tab['A'])) qu'il faut utiliser. bon courage ! Moins le blanc est intelligent, plus le noir lui parait bête |
Bonjour,
|