0
Good morning, as I can do to leave the radiobutton selected according to the database, I have a table in the database with the categories being listed in a foreach on the radiobutton, until then beauty, works to insert, but when editing I need a radiobutton to be selected according to the id that is in the products table related to the id field of the table of categories, 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;
?>
how the last option of the bank as in the radiobuttons is selected.
With this code what happens? Do any errors? Any
radiobutton
appears marked?– Roberto de Campos
appears the last radiobutton marked, in all, once q and to appear marked in the option named in the bank
– Senpai
I imagined it was just that, I posted an answer.
– Roberto de Campos
very obg worked out
– Senpai