I can’t seem to work out how to insert multiple checkbox values into a mysql database with php.
As you know, check boxes are for selecting multiple options in the same group. I have a form with three checkboxes, but when I submit the form, only the bottom-most checked box value is inserted into the database.
How do I get them all the checked options in there?
I suggest you review the data you are recieving prior to using it.
Use print_r($_POST) to review all the data you are receiving and then decide how you are going to process the input.
[color=black]If I recall correctly you will be getting multiple $_POST[“entry_type”] data pairs and you need to process all of them. You may want to concantenate them with $entry_type .= $_POST[“entry_type”]; in a for loop or you may want to store each individually. Depends upon desire to do a look on the data and ease of displaying it.[/color]
where I’ve checked the “homepage” checkbox and “investor” checkbox. Then the data that appears in the mysql table is “Array”, not “homepage” or “investor”.
So using my actionscript knowledge, I included a for loop in the sql query on the php page, so the page goes:
By the look of it, my application of the for loop is incorrect (as my printed data tells me) and it creates bad syntax in the sql query.
I just want to add a string of values to the entry_type column in the mysql table. Eg. “homepage investor” or “investor” or “homepage investor customer”.
Hey thanks, that works. I had a quick look on php.net for a string slice function but only found array_slice. So what’s the best way to get rid of the “s:8” (it’s the number of characters in the posted value)? It’s easiest in the end if my value just equals the value I gave the checkbox.