Good morning, how can I make the radiobutton selected according to the database, I have a table in the bank with the categories being listed in a foreach on the radiobutton, until the beauty, it works to insert, but at the time of edit I need a radiobutton to be selected according to the id that is in the products table related to the id field of the category table, and in that part I am not able to do, my code below:
<?php
foreach($listar_categorias as $categoria):
if($categoria['id'] == $campos['categoria']){ $check = 'checked';}
?>
<input type="radio" name ="cat_select" value="<?php $categoria['id']; ?>" checked="<?php echo $check; ?>" required="require" /><p><?php echo $categoria['nome']; ?></p>
<?php
endforeach;
?>
As the last option of the bank as in the radiobuttons is selected.