I have the following code, where I select categories from a MYSQL table.
<?php
include 'conect.php';
// array que conterá as categorias
$cats = array();
$sql = "SELECT id_carac, nome_carac FROM carac";
$exec = $con->query( $sql ) or exit( $con->error );
$i = 1;
while ( $f = $exec->fetch_object() )
{
$cats[$i]['id_carac'] = $f->id_carac;
$cats[$i]['nome_carac'] = $f->nome_carac;
$i++;
}
foreach ($cats as $key => $value) {
echo "<label><input type='checkbox' name='categoria[]' value='{$value['id_carac']}' > {$value['nome_carac']}</label></br>";
}
?>
This way I can display the selected content, however I have the difficulty of putting each item in a way that generates a checkbox list.
How to display this checkbox list dynamically?
Following the response from @fernandoandrade the above code is working.