par
Laurent V. » 16 juil. 2014, 22:55
Bonjour,
Je cherche à prendre les valeurs des checkbox pour les mettre dans une requête mysql du type WHERE ... IN($array)...
J'ai essayé avec
$in_clause = array();
foreach($_GET['check_list'] as $v)...
Si je vais un var_dump($_GET['check_list']), j'ai: array(2) { [0]=> string(3) "one" [1]=> string(3) "two" }
Code : Tout sélectionner
<form action="index2.php" method="get">
<input type="checkbox" name="check_list[]" alt="Checkbox" value="one">One
<input type="checkbox" name="check_list[]" alt="Checkbox" value="two">Two
<input type="checkbox" name="check_list[]" alt="Checkbox" value="three">Three
<input type="submit" value="Submit">
if(!empty($_GET['check_list']))
{
foreach($_GET['check_list'] as $check)
{
$ids = implode(',', $check);
echo $ids;
}
}
$sql="SELECT * FROM table WHERE activity IN($ids)";
I've tried with array(), implode(), explode()...
Nothing works.
this is a simplified code: I did not put the code against injection.
Can anybody be of help. Thanks :)
Bonjour,
Je cherche à prendre les valeurs des checkbox pour les mettre dans une requête mysql du type WHERE ... IN($array)...
J'ai essayé avec
$in_clause = array();
foreach($_GET['check_list'] as $v)...
Si je vais un var_dump($_GET['check_list']), j'ai: array(2) { [0]=> string(3) "one" [1]=> string(3) "two" }
[code]
<form action="index2.php" method="get">
<input type="checkbox" name="check_list[]" alt="Checkbox" value="one">One
<input type="checkbox" name="check_list[]" alt="Checkbox" value="two">Two
<input type="checkbox" name="check_list[]" alt="Checkbox" value="three">Three
<input type="submit" value="Submit">
[/code]
[php]
if(!empty($_GET['check_list']))
{
foreach($_GET['check_list'] as $check)
{
$ids = implode(',', $check);
echo $ids;
}
}
$sql="SELECT * FROM table WHERE activity IN($ids)";
I've tried with array(), implode(), explode()...
Nothing works.
this is a simplified code: I did not put the code against injection.
Can anybody be of help. Thanks :)
[/php]