Php - insert values ​​of multiple flags

the site I will link to is

http://www.iaddesignandstudio.com/offline select the quote tab

if the person filling out this form selects more than one checkbox in the number 1 or 3. How would I insert these selected values ​​into the database so that when I return the information that the user entered or selected, can I select which checkboxes?

+3
source share
3 answers

You can set your flags in one array after submitting the form by adding []an attribute to the end name, for example:

<input type="checkbox" name="services[]" value="Podcasting Services" /> 
Podcasting Services      
<input type="checkbox" name="services[]" value="Local Search" />Local Search

, $_POST['services'] , . :

#var_dump($_POST['services']);
array(2) {
  [0]=>
  string(19) "Podcasting Services"
  [1]=>
  string(12) "Local Search"
}

, , , ether foreach() implode(), .

, !

+4

. 1, $_POST ['admycomp'] $_POST ['provideresource'] . , 1 admycomp provideresource. , , .

+2

I would suggest storing the values ​​in your database in order to use the SET data type (for example: http://dev.mysql.com/doc/refman/5.0/en/set.html ). This will save each of the flag values ​​from the group of flags in one column in an efficient way of storing. You may need to use implode as described above to create an SQL query to insert your set.

0
source

All Articles