We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7821
    • 3 Posts
    Hi, still a modx rookie.

    I have a checkbox tv which draws from a db table and users can select more than one item from the generated list. I then pass that to a snippet where I use it to pull more information from the db based on the selections. It works when one checkbox is selected but not when two. Here is the the snippet code:

    $output = ’’;

    $sql = $modx->db->query( "SELECT name, email FROM employee where name=’$name’");
    $result_arr = $modx->db->makeArray( $sql );
    foreach($result_arr as $item)
    {
    $params[’name’]=$item[’name’];
    $params[’email’]=$item[’email’];

    $output.=$modx->parseChunk(’displayTpl’, $params, ’[+’, ’+]’);
    }
    return $output;

    I am using evolution. Anybody see what I’m doing wrong? Any help would be greatly appreciated.
      • 33968
      • 863 Posts
      Have you got anywhere with this?

      I think I see what is going on here. Your mySql query is set up to receive only one value, which is why it works when only one TV value is selected.

      What you need to do is set your TV output type to ’Delimiter’, then use a comma ’,’ as the delimiter.
      This will output your selected names as Name1,Name2,Name3 (instead of Name1Name2Name3).

      Then go into your snippet and change your query to:
      SELECT name, email FROM employee WHERE name IN ($name);
      


      Give that a go and see if it works for you...
        • 7821
        • 3 Posts
        This was the problem, thanks for the help it relieved much frustration.