0

I'm trying to do an SQL search from a multiple checkbox with three options :

  • Basico
  • Avancado
  • Interm

When the two first options are selected I suppose i'll have something like this :

SELECT * 
FROM candidates 
WHERE catiav4 LIKE %Avançado% 
  OR catiav4 LIKE %Basico% 
ORDER BY candidate_id DESC 
LIMIT :debut,20 

For that need I use bindParam this way

if ($metier13 != ''){
$metier13=implode("% OR catiav4 LIKE %",$metier13);
$metier13="%$metier13%";
$retour->bindParam(':catiav4', $metier13, PDO::PARAM_STR);}

It works fine when only one checkbox is selected, but when two are selected it does not return any results.

I believe I'm missing something but can't seen to find it.

рüффп
  • 5,172
  • 34
  • 67
  • 113
Lasz
  • 1
  • I understand now my error comes from the fact that PDO adds quotes around the value. But would there be any solution to add these OR catiav4 LIKE anyway ? – Lasz Jul 27 '15 at 14:00
  • it only seems logical that bindParam accepts only one value. you can try to bind param for each value in your query builder. – Bulat Jul 27 '15 at 14:01

0 Answers0