multiple selection input checkbox materialize does not work

1

I'm using the Materialize library, grabbing the data from the database and listing it on the front end, but multiple selection does not work:

<div class="row">
	<form action="#">
		<span>
			<?
			$sql = "SELECT * from $ufEstab where cidade = '{$cidadeEstab}' group by bairro";
			$query = mysqli_query($conexao,$sql);
			while ( $ln = mysqli_fetch_array($query)) {?>
				<div class="col s4">
					<input value="<?= utf8_encode($ln['bairro']);?>" type="checkbox" name="bairro" id="test5" />
					<label for="test5"><?= utf8_encode($ln['bairro']);?></label>
				</div>
			<? }//fim do while bairros ?>
		</span>
		<button class="btn">Cadastrar bairros</button>
	</form>
</div><!--row-->
    
asked by anonymous 02.04.2016 / 03:29

1 answer

2

Switch from:

<input value="<?= utf8_encode($ln['bairro']);?>" type="checkbox" name="bairro" id="test5" />

To:

<input value="<?= utf8_encode($ln['bairro']);?>" type="checkbox" name="bairro[]" id="test5" />

Adding to the name of the input [] , when submitting the form it will be sent as an array of multi-choice.

    
02.04.2016 / 08:11