-1
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, but I have the difficulty of putting each item in a way that generates a checkbox list.
How to view this checkbox list dynamically?
Following @fernandoandrade’s reply the above code is working.
Do not use stacksnippets unnecessarily, please read help and see the best ways to format text for specific situations: http://answall.com/help/formatting
– Guilherme Nascimento
Use HEREDOC to dynamically generate the list.
– Daniel Gomes Da Silva Moreira