Where multiselect filter on array

Where multiselect filter on array

CapamaniaCapamania Posts: 229Questions: 79Answers: 5
edited November 2016 in Editor

I have a multiselect filter which works great if a specifc id has only one value allocated.

account_mm:

id iso_01
1 DE
2 DE
3 FR
4 FR
5 US

But what if a specifc id has multiple values like:

account_mm

id iso_01
1 DE
2 DE
3 FR, DE
4 FR, DE, US
5 US

I tried this but no result:

$id->or_where( 'account_mm.iso_01', '%'.$_POST["selectID"].'%'[$i], 'LIKE'  );

I also tried ....

$id->or_where( 'account_mm.iso_01', $_POST["%selectID%"][$i], 'LIKE'  );

... which does some filtering but shows all the rows with a value in it.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin
    Answer ✓

    A combination of the first two:

    $id->or_where( 'account_mm.iso_01', '%'.$_POST["selectID"][$i].'%', 'LIKE'  );
    

    You want it to look like WHERE account_mm.iso_01 LIKE '%searchTerm%' eventually.

    Allan

  • CapamaniaCapamania Posts: 229Questions: 79Answers: 5

    Perfect ... this works for me. Many thanks

This discussion has been closed.