0
I made a code with explode
to carry checkbox
of banco
, however, it is only loading when it contains data in the exact order of variables, for example 'Theater 1, Theater 2' carries, but 'Theater 1, Baby Class' does not carry any...
Although I have designed for only two options I made a test with a insert
of three, out of order: 'Theatre 2, Theatre 1, Dance 1', carried only 'Dance 1''
<?php $Oficina == $Oficina_Explode;
$Oficina_Explode = explode(', ', $Oficina);
$Oficina_Explode[0]; //ganha o valor 'Teatro 1'
$Oficina_Explode[1]; //ganha o valor 'Teatro 2
$Oficina_Explode[2]; //ganha o valor 'Dança 1'
$Oficina_Explode[3]; //ganha o valor 'Dança 2'
$Oficina_Explode[4]; //ganha o valor 'Baby Class'
?>
<meta charset="utf-8">
<label class="container">Teatro 1 <input class='shared' type='checkbox' value="Teatro 1" name="Oficina[]" required="required" <?php if($Oficina_Explode[0] == 'Teatro 1') echo 'checked';?> /><span class="checkmark"></span></label>
<label class="container">Teatro 2 <input class='shared' type='checkbox' value="Teatro 2" name="Oficina[]" required="required" <?php if($Oficina_Explode[1] == 'Teatro 2') echo 'checked';?> /><span class="checkmark"></span></label>
<label class="container">Dança 1 <input class='shared' type='checkbox' value="Dança 1" name="Oficina[]" required="required" <?php if($Oficina_Explode[2] == 'Dança 1') echo 'checked';?> /><span class="checkmark"></span></label>
<label class="container">Dança 2 <input class='shared' type='checkbox' value="Dança 2" name="Oficina[]" required="required" <?php if($Oficina_Explode[3] == 'Dança 2') echo 'checked';?> /><span class="checkmark"></span></label>
<label class="container"> Baby Class<input class='shared' type='checkbox' value="Baby Class" name="Oficina[]" required="required" <?php if($Oficina_Explode[4] == 'Baby Class') echo 'checked';?> /><span class="checkmark"></span></label>
How can I increment my code to solve this problem?
Confirmed if the value stored in the array is really the string you want?
– MagicHat
I did the tests, I just saw that it’s not about accent... it’s only loading when it contains data in the exact order of variables, for example 'Theater 1, Theater 2' carries, but 'Theater 1, Baby Class' does not carry any...
– Raul Meira
If you entered with 'Teatro 2, Teatro 1, Dança 1', what guarantees you that $Oficina_explode[0] will have the value "Teatro 1", $Oficina_explode[1] will have the value "Teatro 2"? I imagine you’re missing information
– JrD