Ir para conteúdo
Fórum CódigoFonte.net
gustavo.santoshc

Campo Multiple + MySQL

Recommended Posts

Pessoal boa noite,

Por favor gostaria de um help de voces. Tenho um campo multiple (de serviços) e ao selecionar a(s) opção(ões) quero que seja gravada no BD, porem esta gravando somente a palavra "Array". Como posso resolver este problema? Segue codigo abaixo:

      

                 <form name="cadfunc" class="form-horizontal" method="POST" action="processa/proc_cad_funcionario.php">
            </div>

          <div class="col-md-12">              

              <div class="form-group">
                <label for="nome">Nome*:</label>
                <input type="text" class="form-control" id="nome" name="nome" placeholder="Informe o Nome"  autofocus>
              </div>
         

                  <?php
                    if(isset($_POST['cadastrar']))
                  {
                    $opcao = $_POST['id_servico'];
                    $contar = count($opcao);
                      for($i=0; $i<$contar; $i++)
                      {
                        echo $opcao[$i];

                        if($contar -1 != $i){echo ', ';}
                      }
                    }
                  ?>
                  
                  <div class="col-md-2">
                      <label for="id_servico">Serviços:</label>
                        <select  name="id_servico[ ]" multiple="multiple">
                              <option value="1">escova</option>
                              <option value="2">hidratacao</option>
                              <option value="3">relaxamento</option>
                              <option value="4">tintura</option>
                              <option value="5">PE + MAO</option>                           
                        </select>
                        
                    </div>                  
      </div>

        <button type="submit" name="cadastrar" value="cadastrar" class="btn btn-success">Cadastar funcionario</button>
        <a class="btn btn-primary" href="listar_funcionarios.html" id="toggleNavColor">Listar funcionarios</a>
        <button type="reset" class="btn btn-default">Cancelar</button>
</div>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Visitante
Responder

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Processando...

×
×
  • Criar Novo...