0
I have a form that in certain fields returns me several possibilities of data in a single index when I print the array
. This situation can be seen in índices 3, 4, 5 e 7
.
Array
(
[0] => APARTAMENTO
[1] => CASA
[2] => CASA EM CONDOMINIO
[3] => COBERTURA/COBERTURA HORIZONTAL
[4] => CONJUNTO/SALA/LOJA
[5] => FLAT/LOFT
[6] => PREDIO COMERCIAL
[7] => TERRENO/AREAS
)
I need to get to this result in PHP
so that then I can start my queries in the database:
Array
(
[0] => APARTAMENTO
[1] => CASA
[2] => CASA EM CONDOMINIO
[3] => COBERTURA
[4] => COBERTURA HORIZONTAL
[5] => CONJUNTO
[6] => SALA
[7] => LOJA
[8] => FLAT
[9] => LOFT
[10] => PREDIO COMERCIAL
[11] => TERRENO
[12] => AREAS
)
I arrived at this result with this form:
<input type="checkbox" name="tipo[]" value="APARTAMENTO" id="tp1">
<label for="tp1">Apartamento</label>
<input type="checkbox" name="tipo[]" value="CASA" id="tp2">
<label for="tp2">Casa</label>
<input type="checkbox" name="tipo[]" value="CASA EM CONDOMINIO" id="tp3">
<label for="tp3">Casa Condomínio</label>
<input type="checkbox" name="tipo[]" value="COBERTURA/COBERTURA HORIZONTAL" id="tp4">
<label for="tp4">Cobertura</label>
<input type="checkbox" name="tipo[]" value="CONJUNTO/SALA/LOJA" id="tp5">
<label for="tp5">Conjunto/Sala/Loja</label>
<input type="checkbox" name="tipo[]" value="FLAT/LOFT" id="tp6">
<label for="tp6">Flat/Loft</label>
<input type="checkbox" name="tipo[]" value="PREDIO COMERCIAL" id="tp7">
<label for="tp7">Prédio Comercial</label>
<input type="checkbox" name="tipo[]" value="TERRENO/AREAS" id="tp8">
<label for="tp8">Terreno/Área</label>
Passing only that as instruction:
$tipo = $_GET['tipo'];
For layout reasons, I cannot make these fields different, like um tipo por input
. Any idea??
It depends on how you are grouping. Maybe a loop + explodes in / resolve, but I think you are grouping wrong.
– Papa Charlie
You need to show the code/query that generates
item1/item2
, how is this form? How did you get to this array?. . . . If I may criticize a little, I notice that you usually lack this kind of information in your questions.– brasofilo
Since you’re gathering in the field
value="OPÇÃO 1/OPÇÃO 2"
, a loop resolves. Another solution would be to mount via JS with hidden cmapos.– Papa Charlie
I don’t know how to treat
arrays
, can give me a way??– Marcos Vinicius