6
I don’t know how to start this whole process of sending multiple data for a query in the database. I always send an item from each guys but I never sent several items of the same guy. The image below will illustrate better:
I would like you to help me with concepts so that I can achieve the desired result. I imagine it has everything to do with capturing values and storing variables in arrays but I don’t know much more than that.
For logic, I think I would select properties from all cities presented, then type of property and then number of dorms, at least I think it would be like this. I would like to know the whole process since the HTML
until the consultation.
Modification: I put this url http://axitech.com.br/_testes/checkbox.php what I’ve done so far. I’ve done the HTML
of the three results I have to capture with PHP in the form of array.
</body>
<form>
<p>Selecione a cidade: </p>
<input type="checkbox" name="cidade[]" value="Campo Grande">Campo Grande<br>
<input type="checkbox" name="cidade[]" value="Dourados">Dourados<br>
<input type="checkbox" name="cidade[]" value="Três Lagoas">Três Lagoas<br>
<input type="checkbox" name="cidade[]" value="Corumbá">Corumbá<br>
<input type="checkbox" name="cidade[]" value="Naviraí">Naviraí<br>
<input type="checkbox" name="cidade[]" value="Paranaíba">Paranaíba<br>
<input type="checkbox" name="cidade[]" value="Aquidauana">Aquidauana<br><br>
<p>Tipo de imóvel: </p>
<input type="checkbox" name="imovel[]" value="Apartamento">Apartamento<br>
<input type="checkbox" name="imovel[]" value="Casa">Casa<br>
<input type="checkbox" name="imovel[]" value="Comercial">Comercial<br>
<input type="checkbox" name="imovel[]" value="Terreno">Terreno<br>
<input type="checkbox" name="imovel[]" value="Condomínio">Condomínio<br><br>
<p>Selecione a quantidade de dormitórios: </p>
<input type="checkbox" name="dormitorios[]" value="1 Dormitório">1 Dormitório<br>
<input type="checkbox" name="dormitorios[]" value="2 Dormitórios">2 Dormitórios<br>
<input type="checkbox" name="dormitorios[]" value="3 Dormitórios">3 Dormitórios<br>
<input type="checkbox" name="dormitorios[]" value="4 Dormitórios">4 Dormitórios<br>
<input type="checkbox" name="dormitorios[]" value="5 Dormitórios">5 Dormitórios<br>
</form>
In the case of my code presented in this link http://axitech.com.br/_testes/checkbox.php
foreach
takes data fromcheckboxs
, who would be mine$array
?– Marcos Vinicius
$_POST['cities'], because when you use the "cities[]" statement you create the following structure: $_POST = array('cities' => array(0 => 'first', 1 => 'second'))
– Wallace Maxters
In this case, you have a multidimensional array, where $_POST['city'], $_POST['dormitorio'] and $_POST['dormitorios'] are arrays. Try using
var_export
in $_POST to check this information– Wallace Maxters
Fine, but now remember that I can receive more than one
array
, up to several. I have to do oneselect
each time taking the previous result as a basis or I can do all theselects
together or even useif/else
? Like, if there’s a town, do the nextselect
?!?!?!– Marcos Vinicius
Just to reinforce: The
array $array
is the argument of the anonymous function $parseInQuery. $_POST['cities'] is passed as argument then to get the snippet of the MYSQL code in$queryData
– Wallace Maxters
Yeah, but I got
cidade
,imovel
,dormitorio
, how to join the 3 in oneselect
only?– Marcos Vinicius
If any array is empty, this will generate an error or will simply be ignored by
select
?– Marcos Vinicius