We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45118
    • 123 Posts
    Quote from: Jako at Oct 22, 2015, 09:27 PM
    Quote from: redhen at Oct 22, 2015, 02:26 PM

    The error log says "PHP Parse error: syntax error, unexpected 'foreach' (T_FOREACH)".
    There is a semicolon missing after the $i = 0 in my code.
    Hi Jako,
    I made the correction and tested it again. This solution doesn't handle two checked checkboxes correctly. It gives a result of 0 products...
    I think I'll go with Bob's solution for now. Thanks anyway!
    • Quote from: redhen at Oct 23, 2015, 03:42 PM

      This solution doesn't handle two checked checkboxes correctly. It gives a result of 0 products...
      I think I'll go with Bob's solution for now. Thanks anyway!

      It should work (a similar one works in an actual project), maybe the comparison parameter is missing after the 'pre'.

      $i = 0
      foreach($group as $selected) {
          $condition = ($i) ? 'OR:' : '';
          $c->where(array($condition.'pre:=' => $selected));
          $i++;
      }


      But since Bobs solution is working well, use his one.
      • discuss.answer
        • 45118
        • 123 Posts
        Quote from: Jako at Oct 23, 2015, 06:05 PM
        It should work (a similar one works in an actual project), maybe the comparison parameter is missing after the 'pre'.

        $i = 0
        foreach($group as $selected) {
            $condition = ($i) ? 'OR:' : '';
            $c->where(array($condition.'pre:=' => $selected));
            $i++;
        }


        But since Bobs solution is working well, use his one.

        That did the trick! Thank you!