makoshark Posted June 6, 2009 Share Posted June 6, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/161149-foreach-checkbox-insert-state-checked-not-cheked-into-mysql/ Share on other sites More sharing options...
.josh Posted June 6, 2009 Share Posted June 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/161149-foreach-checkbox-insert-state-checked-not-cheked-into-mysql/#findComment-850391 Share on other sites More sharing options...
makoshark Posted June 6, 2009 Author Share Posted June 6, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/161149-foreach-checkbox-insert-state-checked-not-cheked-into-mysql/#findComment-850687 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.