le 14/09/2009 à 17:18
Sondage
Oui jeca ça marche, merci
<?php if(!empty($_POST['choix'.$nombre_de_verifs.'']))
{
$message = '<strong><a href="afficher_sondage.php">ici</a></strong>';
mysql_query("INSERT INTO sondage_choix VALUES ('', ?, ?, '".$_POST['choixmachin']."'");
} ?>
<?php
$nb_rep = $_POST['nb_rep'];
if (isset($_POST['question']))
{
if(!empty($_POST['question']))
{
$ok = true;
for($nombre_de_verifs = 0; $nombre_de_verifs <= $nb_rep; $nombre_de_verifs++)
{
if(isset($_POST['choix'.$nombre_de_verifs]))
{
if(!empty($_POST['choix'.$nombre_de_verifs.'']))
{
$message = '<strong><a href="afficher_sondage.php">ici</a></strong>';
}
else
{
$ok = false;
break;
}
}
}
}
elseif(empty($_POST['question']))
{
echo '<strong>No</strong>';
}
}
if(isset($ok))
{
if($ok == true)
{
echo $message;
// Je me connecte à la base de données
include("../includes/identifiants.php");
mysql_connect($adresse, $nom, $motdepasse);
mysql_select_db($database);
// Je balance le tout dans la table sondages
$auteur = $_SESSION['pseudo'];
$question = $_SESSION['question'];
mysql_query("INSERT INTO sondages VALUES('','".$auteur."','','','1')") or die(mysql_error());
//Je récupère l'id de ma table sondages
$id_sondages = mysql_insert_id();
// J'insère maintenant mes données dans sondage_question
mysql_query("INSERT INTO sondage_question VALUES('','".$id_sondages."','".$question."')") or die(mysql_error());
// Je recupère maintenant l'id de ma table sondage_question
$id_sondage_question = mysql_insert_id();
// Insertion
mysql_query
("
INSERT INTO sondage_choix (sondage_choix_id, sondage_id, sondage_question_id, sondage_choix, sondage_nb_vote)
VALUES(),()
") or die(mysql_error());
}
}
?>