- Code: Tout sélectionner
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("enquete");
$question = $_POST['question'];
$description = $_POST['description'];
$type_s = $_POST['type_s'];
$requete = "insert into question (nom_qestion,description,id_type_q) values('" . $question . "','" . $description . "','" . $type_s . "')";
$sql = mysql_query($requete);
$req = mysql_query("select * from question");
$choix = $_POST['choix'];
while ($tab = mysql_fetch_object($req)) {
if ($tab->id_type_q == 3) {
$selection = mysql_query("select id_question as selection from question where id_type_q=3");
while (list($key, $val) = @each($choix)) {
for ($i = 0; $i < $key; $i++) {
$insertion = "insert into choix_critere (id_choix_c,id_question,nom ) values('" . $i . "','" . $selection . "','" . $val . "') ";
echo ($insertion);
$res = mysql_query($insertion);
}
}
}
}
?>
merci