INSERT INTO tk_sondages VALUES (NULL,NOW(),"1", "vos gouts en cuisine", "miam youpi!"," DP, DS, DA, V, ON, T, N, C, S, G","","","","","","","",""),(NULL,NOW(),"","","","DP","Votre pseudo","","1","","","","",""),(NULL,NOW(),"","","","DS","Votre sexe","","1","","","","",""),(NULL,NOW(),"","","","DA","Votre âge","","1","","","","",""),(NULL,NOW(),"","","","T","lieu de naissance","","1","","","","",""),(NULL,NOW(),"","","","T","nb d'enfants","","1","","","","",""),(NULL,NOW(),"","","","T","nb d'enfants","","1","","","","",""),(NULL,NOW(),"","","","T","vous aimez les frites?","","1","","","","",""),(NULL,NOW(),"","","","T","pays","France, Belgique, ailleurs","1","","","","",""),(NULL,NOW(),"","","","T","cheveux","blonds,bruns,bleus","1","","","","",""),(NULL,NOW(),"","","","T","estime de soi","1","1","","","","","") cible 3 Et là genre ça enregistre le sondage, tavu! liste des sondages



$v) { echo' $_POST '.$k.' => '.$v.'
';} $retour= mysql_query("SELECT COUNT(*) as nbre from tk_tbl_options"); $donnes = mysql_fetch_array($retour); print_r($donnes); $max_option= $donnes['nbre'] ; $premier_id_option =$max_option+1; echo"Il ya $max_option options dans la table des options, on enregistrera alors à partir de la $premier_id_option eme"; $retour= mysql_query("SELECT count(id) as nb from tk_tbl_sondage"); $donnes = mysql_fetch_array($retour); print_r($donnes); $max_sondage= $donnes['nb'] ; $id_sondage = $max_sondage + 1; $dernier_id_option=$premier_id_option+$nb_choix; echo"Il ya $max_sondage sondages dans la table des options, on enregistrera alors le $id_sondage eme"; $tadam = array("sondage $id_sondage","titre $titre"," sous titre $question","premier choix id $premier_id_option","dernier choix id $dernier_id_option","","","date $date"); echo"


MAINTENANT ON ENREGISTRE:

"; print_r($tadam); if (isset($_POST['titre'])) //ENREGISTREMENTS { // DU SONDAGE DANS LA TABLE DES SONDAGES $id_sondage = $max_sondage + 1; $sql_sondage="INSERT INTO tk_tbl_sondage VALUES (NULL, '".$titre."', '".$question."','".$premier_id_option."','".$dernier_id_option."','','','".$date."')"; echo"



enregistrer le sondage:
$sql_sondage

"; //addition des BOOLEANS //////////// OUI NON ///// radio $sql_options_radios= 'INSERT INTO tk_tbl_options VALUES '; for ($i=0 ; $i < $nb_booleans ; $i++) { $radio= $_POST['radio'.$i.'']; $sql_options_radios .=' (NULL, " '.$radio.'","1",NULL,NULL,NULL,"'.$id_sondage.'" ),'; //radios } $sql_options_radios = substr( $sql_options_radios ,0,-1); $sql_options_radios .= ''; //ADDITION DES TEXTES//////////// TEXTE $sql_options_textes= 'INSERT INTO tk_tbl_options VALUES '; for ($i=0 ; $i < $nb_textes ; $i++) { $texte= $_POST['texte'.$i.'']; $sql_options_textes .=' (NULL, " '.$texte.'",NULL,NULL,"1",NULL,"'.$id_sondage.'" ),'; //varchar } if ($_POST[demander_pseudo]=='oui') { $demande= "Votre pseudo:"; $sql_options_textes .=' (NULL, " '.$demande.'",NULL,NULL,"1",NULL,"'.$id_sondage.'" ),'; //varchar } $sql_options_textes = substr( $sql_options_textes ,0,-1); $sql_options_textes .= ''; if ($_POST[choix]!=0) { //addition des CHOIX DE VOTES //////////// NB_CHOIX ///// choix $sql_options= 'INSERT INTO tk_tbl_options VALUES '; for ($i=0 ; $i < $nb_choix ; $i++) { $choix= $_POST['choix'.$i.'']; $sql_options .=' (NULL, " '.$choix.'",NULL,"1",NULL,NULL,"'.$id_sondage.'" ),'; //radio } $sql_options = substr( $sql_options ,0,-1); $sql_options .= ''; } //addition des NOMBRES ////// nb_nombres /////// nombres $sql_options_nombres= 'INSERT INTO tk_tbl_options VALUES ';//plop for ($i=0 ; $i < $nb_nombres ; $i++) //plop { $nombres= $_POST['nombres'.$i.''];//plop $sql_options_nombres .=' (NULL, " '.$nombres.'",NULL,NULL,NULL,"1","'.$id_sondage.'" ),'; //nombres } //plop $sql_options_nombres = substr( $sql_options_nombres ,0,-1); $sql_options_nombres .= ''; //addition des listes ////// nb_listes /////// listes $sql_options_listes= 'INSERT INTO tk_tbl_options VALUES ';//plop for ($i=0 ; $i < $nb_listes ; $i++) //plop { $nom_liste= $_POST['listes'.$i.''];//plop $sql_options_listes .=' (NULL, " '.$nom_liste.'",NULL,NULL,NULL,"1","'.$id_sondage.'" ),'; //varchar for ($i=0 ; $i < $nb_options ; $i++) //plop { $opt_liste= $_POST['listes'.$i.'option'.$i.''];//plop $sql_options_listes .=' (NULL, " '.$opt_liste.'",NULL,NULL,NULL,"1","'.$id_sondage.'" ),'; //varchar } } //plop $sql_options_listes = substr( $sql_options_listes ,0,-1); $sql_options_listes .= ''; // echo"compteur: $i
$sql_options
"; echo"


"; echo"compteur pour textes: $i
$sql_options_textes
"; echo"compteur pour radios oui/non: $i
$sql_options_radios
"; echo"compteur pour votes: $i
$sql_options
"; echo"compteur pour nombres: $i
$sql_options_nombres
"; echo"compteur pour listes: $i
$sql_options_listes
"; echo"


"; // mysql_query( // $sql_options // ) or die( "NIMPPPPPPP
$sql_options
".mysql_error()); //MYSQL_QUERY ENREGISTREMENNNNNNNNNNNNNNNTS mysql_query(' INSERT INTO tk_tbl_sondage VALUES ("'.$id_sondage.'", "'.$titre.'", "'.$question.'", "'.$premier_id_option.'", "'.$dernier_id_option.'", "", "", "'.$date.'" ) ') ; if ($_POST['boolean']!=NULL) { echo" booléens oui non enregistrés!
"; mysql_query( $sql_options_radios ) or die( "NIMPPPPPPP radio
$sql_options_radios
".mysql_error()); } if (isset($_POST[texte])) { echo" textes enregistrés!
"; mysql_query($sql_options_textes) or die( "NIMPPPPPPP texte
$sql_options_textes
".mysql_error()); } if (isset($_POST[nombres])) { echo" nombres enregistrés!
"; mysql_query($sql_options_nombres) or die( "NIMPPPPPPP nombres
$sql_options_nombres
".mysql_error()); } if (isset($_POST[listes])) { echo" listes enregistrées!
"; mysql_query($sql_options_listes) or die( "NIMPPPPPPP listes
$sql_options_listes
".mysql_error()); } if ($_POST[choix]!=0) { echo" votes enregistrés!
"; mysql_query($sql_options) or die( "NIMPPPPPPP votes
$sql_options
".mysql_error()); } echo" tout à été enregistré!
"; // FIN DE L'ENREGISTREMENT ------------------------------- } echo "

Sondages dans la table:

"; $sql='SELECT * from tk_tbl_sondage '; $retour=mysql_query("$sql") or die( $sql."
". mysql_error()); while ($donnes=mysql_fetch_array($retour)) { echo "$donnes[0], $donnes[1] , $donnes[2], $donnes[3], $donnes[4], $donnes[5], $donnes[6], $donnes[7]
"; } foreach ($_POST as $k => $v) { echo' ';} mysql_close(); ?> liste des sondages

Retour créer un sondage
liste des sondages
bravooo tu as voté! ". mysql_error()); $donnees=mysql_fetch_array($reponse); $id_votant=$donnees[nbr]++; echo'
'; mysql_query($sql) or die( "$sql
". mysql_error()); $POST[saved]=0; echo "id_votant: $id_votant
"; // Il y a 8 votes à ce sondage, t'as vu. $numero_sondage= $_POST[id_sondage]; $vote=$_POST[$numero_sondage]; echo"
sondage n° $numero_sondage. ton vote: $vote
"; ///////////////////////////////////////////////////////// //nb de votes pour le sondage $sql="select count(*) as nbs from tk_tbl_reponse where id_sondage_reponse='".$id_sondage."'"; $reponse=mysql_query("$sql") or die( "$sql
" .mysql_error()); $donnees=mysql_fetch_array($reponse); echo"
Il ya $donnees[nbs] votes pour ce sondage

STATISTIQUES DE RÉPONSE:

"; $votes_totaux=$donnees[nbs]; //choix pour le sondage $compteur=0; $sql="select * from tk_tbl_options where id_sondage='".$id_sondage."'"; $reponse=mysql_query("$sql") or die( "$sql
" .mysql_error()); while($donnees=mysql_fetch_array($reponse)) { $compteur++; $array_choix[$compteur]="$donnees[question]"; } $nb_de_choix=$compteur+1; for ($i=1 ; $i < $nb_de_choix ; $i++) { $sql="select count(*) as nbs from tk_tbl_reponse where id_sondage_reponse='".$id_sondage."' AND radio_reponse='".$i."'"; $reponse=mysql_query("$sql") or die( "$sql
" .mysql_error()); $donnees=mysql_fetch_array($reponse); $votes_choix =$donnees[nbs]; $pourcentage=floor($votes_choix*100/$votes_totaux); $largeur=3*$pourcentage; $reste=(100-$pourcentage)*3; $graphique=" "; echo"
$array_choix[$i] $votes_choix ($pourcentage%) $graphique "; } mysql_close(); ?>