0
I know what you have to do, but I don’t know how to do it.
I have the following array:
$dados = array
0 =>
array
'id' => 1
'posicao' => 1
'ativo' => 'sim'
1 =>
array
'id' => 2
'posicao' => 2
'ativo' => 'sim'
2 =>
array
'id' => 3
'posicao' => 3
'ativo' => 'sim'
3 =>
array
'id' => 4
'posicao' => 4
'ativo' => 'nao'
4 =>
array
'id' => 5
'posicao' => 5
'ativo' => 'nao'
I list each of these items with a loop for
and in each one I have this select
:
<select>
<?php for ($i=0; $i < count($dados); $i++) { //para cada item do array eu faço um option ?>
<h3>Posição</h3>
<option value="<?php echo $dados[$i]['posicao'] ?>" <?php echo $selected = ($dados[$i]['posicao'] == $pos)? 'selected' : ' '; //verifico qual a posicao do item e seleciono?> ><?php echo $dados[$i]['posicao'] ?></option>
<?php } ?>
</select>
So far it is correct, now I need to check in each item of the array if it is active and if it is disabled the option
.
Follow image for didactic question:
I even thought about making this format, but as I commented this code will be inside another loop as well. That is, if position 1 has an item
ativo
it will need to appear for the other item as well and so on.– Lucas Granvilla
I think it will work normal
– Tales Peres