Check box of the database with mysql and php

Asked

Viewed 77 times

-1

How to automatically create check box with data coming from a database table?

  • Do a while/foreach and create checkboxes within it with their id, values and descriptions. You already have some code done, you can ask him the question?

  • I haven’t made the code yet but I will and as soon as I’m done.

  • Need to provide more details, are you using PDO or Mysqli to connect to the bank? what information should the checkbox have? has the query made? add these details to the question.

  • I just made here reusing previous codes and it worked

1 answer

1


<?php 
    $result_categorias = "SELECT * FROM categoria";
    $result_categorias = mysqli_query($conn,    $result_categorias);
    while($row_categorias = mysqli_fetch_assoc($result_categorias)){ 
?>
<input type="checkbox" name"categoria" value="<?php echo $row_categorias['id']; ?>"><?php echo $row_categorias['nome']; ?></option>
<?php } ?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.