Sniark
Messages postés90Date d'inscriptionmercredi 4 juillet 2007StatutMembreDernière intervention22 septembre 2009
-
19 août 2008 à 14:08
Sniark
Messages postés90Date d'inscriptionmercredi 4 juillet 2007StatutMembreDernière intervention22 septembre 2009
-
19 août 2008 à 15:36
Bonjour à tous,
Dans un formulaire, j'ai des SELECT multiple sous forme de listes, dont le contenu est le résultat d'une requête sur ma base de données.
Ensuite, je ré-affiche les choix sélectionnés par l'utilisateur pour confirmation. Maintenant, je cherche à enregistrer chaque choix dans une variable afin de les utiliser dans une requête SQL. Je n'ai aucune idée de comment faire... L'idée, est que si je cherche à enregistrer ce qui a été "POSTé", j'obitiens la valeur ARRAY...
Ce que je cherche à faire :
Si 3 choix ont été fait, je cherche à obtenir :
$Var1 = choix1
$Var2 = Choix2
$Var3 = choix3.
Sniark
Messages postés90Date d'inscriptionmercredi 4 juillet 2007StatutMembreDernière intervention22 septembre 2009 19 août 2008 à 15:36
En fait j'ai trouvé, j'ai fait comme ça
<?
//
// PHP bit used to collect the elements from the list KnownProblemsSelectFormat
//
if(isset($_POST['KnownProblems']) && !empty($_POST['KnownProblems']))
{
$KnownProblemsSelectFormat_Array = $_POST['KnownProblems'];
foreach($KnownProblemsSelectFormat_Array as $selectValue)
{
//
$KnownProblemsSelect += 1; // We incremente a counter here so we know how many results we should expect, AND we get a new $Variable name for each result
${'KnownProblemsSelect'.$KnownProblemsSelect} = $selectValue; // We build variables with dynamic name incrementing with the counter
//
}
}
//
// Here we can now display all the highlighted results 1 by 1!
//
if(isset($KnownProblemsSelect))
{ // If '$counter' exists
echo "You have chosen:"; // We display...
for($i = 0; $i < $KnownProblemsSelect+1; $i++) // (inialize $i variable ; until $i < 'counter +1' ; add 1 to $i)
echo ${'KnownProblemsSelect'.$i}. '
'; // We create a Super Variable composed of $KnownProblemsSelect.and-the-number-contained-in-$i, and we display it
echo "as KnownProblemsSelect format."; // We display the end of the sentence.
}
?>