Ir para conteúdo
Fórum CódigoFonte.net
Entre para seguir isso  
nldj

foreach dentro de for na View

Recommended Posts

<?php
for ($x = 1; $x <= 3; $x++) {
        ?>
        <select class="form-control" name="AreaAtuacao<?php echo $x?>" id="AreaAtuacao<?php echo $x?>" required="required">
              <option value="">Selecione</option>
              <?php foreach ($this->view->areaAtuacao as $areaAtuacao):?>
              <option value="<?php echo $areaAtuacao['IdArea']?>" <?php if($x == $x && $this->view->$AreaAtuacao == $areaAtuacao['IdArea']){echo 'selected';}?>><?php echo $areaAtuacao['Nome']?></option>
              <?php endforeach;?>
        </select>
        <?
}

consigo construir 3 vezes a HTML select tag pelo for, mas só no primeiro loop o foreach funciona.

o que estou fazendo errado? qual o jeito correto de fazer? em procedural antes dava certo.

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...
Entre para seguir isso  

×
×
  • Criar Novo...