Inserting checkbox values into database

前端 未结 6 1372
醉梦人生
醉梦人生 2020-12-10 23:39

I need help for this problem that i\'m trying to solve for a while (i\'m new in PHP). I have a form with several checkboxes which values are pulled from a database. I manage

6条回答
  •  北海茫月
    2020-12-10 23:46

    2nd Answer:

    You might do something like this:

    HTML:

    echo '';
    

    PHP:

    if ( !empty($_POST["id_dodatoci"]) ) {
        $id_dodatoci = $_POST["id_dodatoci"];
        print_r($id_dodatoci);
        // This should provide an array of all the checkboxes that were checked.
        // Any not checked will not be present.
    } else {
        // None of the id_dodatoci checkboxes were checked.
    }
    

    This is because you are using the same name for all of the checkboxes, so their values will be passed to php as an array. If you used different names, then each would have it's own post key/value pair.

    This might help too:

    http://www.php-mysql-tutorial.com/php-tutorial/using-php-forms.php

提交回复
热议问题