Schlo_50 Posted December 5, 2007 Share Posted December 5, 2007 Hello again, Does anybody know of a good tutorial/snippet that teaches one how to use html checkboxes and php to $_POST the data into a database correctly? I've been struggling with this for a while and figure i should justs tart from scratch with it again just so that i can understand it. Thanks Quote Link to comment Share on other sites More sharing options...
asmith Posted December 5, 2007 Share Posted December 5, 2007 what do you want exactlly ? to record a check box when checked into mysql data base ? Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted December 5, 2007 Author Share Posted December 5, 2007 Yes, but eventually there will be loads of checkboxes on the page like a questionnaire, so i will need a way to capture every one that is checked. Quote Link to comment Share on other sites More sharing options...
asmith Posted December 5, 2007 Share Posted December 5, 2007 each checkbox value for each mysql field ? or all in one field ? i'm gonna write you some code, that's why i'm asking Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted December 5, 2007 Author Share Posted December 5, 2007 Well i would prefer all into one field separated by commas. But which ever way is the most efficient i will adopt to make the system work. Quote Link to comment Share on other sites More sharing options...
JacobYaYa Posted December 5, 2007 Share Posted December 5, 2007 The way to use checkboxes is to add [] to the name attribute of the checkbox HTML (name="xxx[]"). This way they will be put into arrays and you can just go $xxxs = $_POST['xxx']; foreach($xxxs as $value){ echo $value; } Quote Link to comment Share on other sites More sharing options...
JacobYaYa Posted December 5, 2007 Share Posted December 5, 2007 Well i would prefer all into one field separated by commas. But which ever way is the most efficient i will adopt to make the system work. Just do as I said with the name="xxx[]" and then implode() and your done. Quote Link to comment Share on other sites More sharing options...
asmith Posted December 5, 2007 Share Posted December 5, 2007 Well i would prefer all into one field separated by commas. But which ever way is the most efficient i will adopt to make the system work. Just do as I said with the name="xxx[]" and then implode() and your done. yea that'll work . no need for me to type Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted December 5, 2007 Author Share Posted December 5, 2007 lol Well thanks anyway asmith and Jacob! Will use that information wisely, thanks again. Quote Link to comment 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.