Insertion dans une bdd de valeurs checkbox

michmich -  
 michmich -
Bonjour,
Je n'arrive pas a ajouter les valeurs de mon checkbox dans ma bdd .
Pourriez vous m'aider a résoudre mes erreurs :
L'erreur viens de la boucle for je ne sais pas si c'est bon comme méthode

<?php
function est_selectionne($option)
{
if (!isset($_POST['interet']))
{
return FALSE;
}
for ($i = 0, $c = count($_POST['interet']); $i < $c; $i++)
{
if ($_POST['interet'][$i] == $option) {
return TRUE;
}
}
return FALSE;
}
?>

<td align="left" valign="top"><p>Vos intérêts <span class="orange">*</span></p></td>
<td><p>Ski<input type="checkbox" name="interet[]" value="ski" <?php if(est_selectionne("ski")) { echo 'checked'; } ?> />
  Rando<input type="checkbox" name="interet[]" value="rando" <?php if(est_selectionne("rando")) { echo 'checked'; } ?> />
  Fête<input type="checkbox" name="interet[]" value="fete" <?php if(est_selectionne("fete")) { echo 'checked'; } ?> />
   Scolaire<input type="checkbox" name="interet[]" value="scolaire" <?php if(est_selectionne("scolaire")) { echo 'checked'; } ?> />
  Professionel<input type="checkbox" name="interet[]" value="pro" <?php if(est_selectionne("pro")) { echo 'checked'; } ?>></p></td>

</tr>

if (isset($_POST['interet']))
{
for ($i = 0, $c = count($_POST['interet']); $i < $c; $i++)
{
$result = mysql_query("
INSERT INTO liste_interet (mail_membre, num_interet)
VALUES(
'" . ($_POST["mail"]) . "'
,'" . ($_POST["interet"][$i]) ."')");
}
}

A voir également:

1 réponse

michmich
 
Bonjour a tous,
Personne pour m'aider ?
0