Wednesday, 15 January 2014

html - Get array from checkbox and then make a string in PHP -


I have a form on my website, which uses an array to submit checkbox data. I then try to manipulate the data with a foreach loop to add "::" to each checkbox data, and then I want to put it in a string, which I put in the database.

This is my HTML code:

  while ($ line = $ result-> fetch_assoc ()) {echo '& lt; Tr & gt; & Lt; Td> & Lt; Input type = "checkbox" name = "plugin list []" value = "'. $ Line [' plugin ']." "" /> Gt;   $ Line ['plugin']. '  

This is my PHP code which is $ _POST The data is, and then runs Foreach loop:

  if (empty ($ _ POST ['pluginlist'])) {foreach ($ _ POST ['pluginlist'] $ forms of plugins } $ {$ Plugins1 = $ plugins} ":";} Echo $ plugins1;}   

counterfeit $ plugins1 only provides the last checkbox data at the end with ":"

How can I create it so that I can check all the checkbox data in one database at a time Insert?

You can do the serialize data, I think it

Or you can try

  $ plugins1 = implode (":", $ _POST ['plugin list']);  < / Pre>  

No comments:

Post a Comment