0
I’m developing an immovable site with a search, where one of the filters is the neighborhood. Currently it is a Dropbox, but I would like to swap by checkbox group to be able to select more than 1 neighborhood at a time, how can I do this?
I thought of some way to send the information more or less like this: (&neighborhoods=center,)
The search is done with the $_GET.
Form:
<form id="buscalancamento" name="nomebuscalancamento" method="get" action="/incorporadora/terrenos">
<select type="text" name="bairro">
<option>Todos</option>
<option>Centro</option>
<option>Tatuape</option>
</select>
<button type="submit"">Buscar</button>
</form>
And the consultation:
$bairro = $_GET['bairro'];
//FILTRO BAIRRO
if (isset($bairro)) {
if($bairro=='Todos'){
$wbairro='';
}else{
$wbairro=' AND bairro LIKE "'.$bairro.'" ';
}
}else{$wbairro='';}
$query=("SELECT *, FROM #__ter_terrenos WHERE id > 0".$wbairro);
$db -> setQuery($query);
I don’t know how to send all chebkox with values together, nor do query with this data sent
Ever tried to exchange LIKE for IN? Since neighborhoods are generated by a select and not informed by the user would not need to use LIKE...
– Lucas Gauna
About using the values sent, they will be sent as array per post or get if post only uses a var_dump($_POST['fieldname']); to check what is coming, then use an IMPLODE to join the array.
– Lucas Gauna
You can also convert Dropbox to Multiple where the user can select several items. Just add
multiple
:<select multiple>
– Sam
@Lucasgauna I will test with the IN, but how do I send the get all selected checkbox together?
– Leandro Marzullo
@sam thought about it, but the customer wanted to checkbox even, by clicking select neighborhood he appears a checkbox group
– Leandro Marzullo
@Leandromarzullo, practically you will have to do it : "'". implode(" ',' ", $array)."'";
– Lucas Gauna
@Leandromarzullo instead of the array you use your checkbox set, remember that their name should be correct, which would be name="checkbox[]". Give a test and return the result here. The most important thing is to var_dump the checkbox field and check whether it’s coming as an array or not.
– Lucas Gauna
ve se entendi, in place of select, I will put something like this: <input type="checkbox" name="checkbox[]" value="Center"> <input type="checkbox" name="checkbox[]" value="Tattooing">? if it is, I did then it appeared on get: checkbox%5B%5D=Centro&checkbox%5B%5D=Tatuape
– Leandro Marzullo
@Leandromarzullo I will be performing some tests please wait a minute, I will be putting as answer
– Lucas Gauna
@Leandromarzullo, you use Jquery?
– Lucas Gauna
@Lucasgauna, I can use
– Leandro Marzullo