Bonjour,
Je crée un site de questionnaire. J'ai fait 95% du travail mais j'ai un problème avec les checkbox. J'ai épuré les forum etc. mais rien donc voilà mon problème.
J'arrive à insérer mes résultat si c'est un textarea et un radio, mais avec les checkbox je n'y arrive pas. En je voudrai enregistrer les checkbox et en un enregistrement donc avec une séparation avec un ;
Là sincèrement si quelqu'un peu m'aider car ça fait 4 jours que je suis dessus j'ai essayer des tonnes de truc mais rien n'y fait.
Même si quelqu'un veut me contacter par email ou messagerie type msn pas de problème car c'est super urgent en plus car c'est professionnel.
Morceau du Formulaire
Traitement Dans une autre page
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 ."<td><input type='hidden'name='question[".$i."]'value='".$id_question."'><img src='./img/puce1.gif'width='10'align='absmiddle'/>" ."<u><b>num question ".$id_question."</b></u> ".$ordre." - <span style='text-align: justify;'>".$question."</span></td>" ."<td width='15%'align='center'>"; IF ($reponse=='oui') { ECHO "<input type='radio' name='reponse[".$i."]'value='oui'/>OUI<input type='radio' name='reponse[".$i."]'value='non'/>NON"; } ECHO "</td>" ."</tr>"; //SI CHOIX MULTI EGAL A OUI ALORS ON AFFICHE LA LISTE IF ($choix_multi=='oui') { ECHO "<tr><td colspan='2'><span style='font-size:10px;'><u>Choix possibles</u></span></td></tr>" ."<tr><td colspan='2'>"; $sql_choix =" SELECT id_choix, id_question, choix, ordre "; $sql_choix .=" FROM $table_choix "; $sql_choix .=" WHERE id_question='$id_question'"; $sql_choix .=" ORDER BY ordre asc"; $resultat_choix = mysql_query($sql_choix); $nb_choix = mysql_num_rows($resultat_choix); WHILE ($list_choix=mysql_fetch_object($resultat_choix)) { $id_choix=$list_choix->id_choix; $id_q=$list_choix->id_question; $choix=$list_choix->choix; echo "<span style='margin-left:90px;'>.id choix<b>".$id_choix."</b><input type='checkbox' name='choix_multi[".$id_question."]'value='".$id_choix."'/></span><br />"; }
Là ça insère la question mais aucun checkbox. Sachant qu'il faudrai que dans la table résultat, il y est par exemple
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 $nombre_question=$_POST['nb_tt_questions']; $i=1; $type_questionnaire=$_POST['type_questionnaire']; $p_id_theme=$_POST['id_theme']; $p_id_client=$_POST['id_client']; $date_maj = date("d-m-Y - H:i"); $p_id_stheme=$_POST['id_stheme']; IF (ISSET ($_POST['AJOUTER']) AND $_POST['AJOUTER']=='Enregistrer' OR ISSET ($_POST['MAJ']) AND $_POST['MAJ']!='') { WHILE( $i <= $nombre_question ) { $p_id_question=$_POST['question'][$i]; $p_reponse=$_POST['reponse'][$i]; $p_commentaire=$_POST['commentaire'][$i]; $date_s = date ("Y/m/d"); $test=$_POST['choix_multi[]']; $choix=implode(';',$test); $names = "id, id_s_theme, id_theme, id_client, id_question, reponse, commentaire, date_s, date_maj, valide_res, valide_du_client, choix_multi "; $values = "'','$p_id_stheme','$p_id_theme','$p_id_client','$p_id_question','$p_reponse','$p_commentaire','$date_s','$date_maj', '0', '0','$choix'"; IF ($type_questionnaire=='QG') { $table = "resultats_qg"; } IF ($type_questionnaire=='QL') { $table = "resultats_ql"; } $req ="INSERT INTO ".$table." (".$names.") VALUES (".$values.")"; mysql_query($req) OR DIE("Impossible de se connecter : " . mysql_error()); $i++; }
Code X : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 id id_question choix_multi 1 1 1 2 2 1;2 etc.
Voilà je t'avoue j'espère que quelqu'un va trouver car là j'en peux plus et c'est vraiment important.
Merci d'avance
Partager