Skip to content Skip to sidebar Skip to footer

Store Multidimensional Checkbox In Database

I want to store checkbox in database.. but the checkbox is a bit complex than regular. Basically this is what I want to implement. I am able to collect data from input and store i

Solution 1:

First: Do you mean to be using radio buttons instead? If the person should only be able to choose Original OR Xerox per row, you might want radio buttons instead of checkboxes.

That said, if you do want checkboxes, the output PHP would be something like:

<?php// loops through each "document" value in the POSTforeach($_POST['document'] as$key => $val) {
    echo$key; // print the key for each value in document (what you treat as a "row"foreach($valas$k => $v) {
       echo" - ".$k; // print EACH value within that key (what you thread as a "column"
    }
    echo"<br/>\n"; // after all columns per row are printed, print a line break
}

Here is a link to a working example: http://myingling.com/random/random/44477622/

Some things worth reading about:

  1. associative arrays
  2. foreach (especially using the $key => $val structure)
  3. the key function

Post a Comment for "Store Multidimensional Checkbox In Database"