foreach always brings the first value in addition to the selected ones

-1

I have a multiple bootstrap select from which I'm using Select2 (Multiple select boxes) . When you select more than one value, the first value of the select always appears without selecting it. See the code:

$multiplo = ($tipo == "Escolas")?("multiple='multiple'"):(null);
$visualizar = "<select name=\"Modulos[]\" class=\"form-control select2\" ".$multiplo." data-placeholder=\"Selecione o módulo\" style=\"width: 100%;\">";

     while($jm = mysqli_fetch_object($sql)){
      $visualizar .= "<option value='".$jm->id_serie."'>".$jm->nome_serie."</option>";
    }
$visualizar .= "</select>";

I'm rescuing using the foreach:

$modulos = $_POST['Modulos']; 
foreach($series as $escolhaSeries){
         echo $escolhaSeries."<br>"
}

Would anyone have any idea why this occurs?

    
asked by anonymous 20.01.2017 / 21:28

1 answer

-1

I managed to resolve. It was a silly mistake, but it could serve as a warning to other colleagues. I put the line:

$visualizar .= "<option value=''>Selecione</option>";
    
20.01.2017 / 21:37