Jump to content

foreach checkbox insert state (checked not cheked) into mysql


makoshark

Recommended Posts

I have been looking around for two days now but all I find is complicated coding for a simple problem here is what I have come up as far as check boxes, there at 13 but I'll just use a few

<blockquote> 
  <input name="question[]" type="checkbox" value="OrderTotalHigh" />  Order total was higher than I expected  <br />
  <input name="question[]" type="checkbox" value="ShippingHigh" />  Cost of shipping too high  <br />
  <input name="question[]" type="checkbox" value="OutOfStock" />  Products out of stock  <br /> 

what I want to do next is a foreach and get the state of the checkbox and its value that matches the Mysql field and populate the database

Thanks for your help

the way you have your form right now, only the ones that are checked will be posted.  If you want to be able to see that ones are non-checked, you need to explicitly specify element positions for question[] in your form. 

 

example:

question[0]

question[1]

question[2]

 

That way, if the user does not check for instance, "OutOfStock", the 3rd element will still be posted, but be empty

 

You would then have your foreach loop and ... beyond that, you need to be more clear about what it is you're trying to do.

Hello

More definition: it is a 13 question check box form were a customer can choose as many as they like for their reason not to buy. the idea is to gather this info when they exit the website.

<input name="question[]" type="checkbox" value="ChangeMind" />  Changed mind about products  <br />

My idea was The value of each question matches the table field thus as it does a foreach places a 1 or 0, true or false into the field of the database. later the data can be pulled up to show the greatest reason there was no sale. I intend to make the end product a free download at my website http://nilandsplace.com

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.