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 "