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 Link to comment https://forums.phpfreaks.com/topic/80242-suggestions/ 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 ? Link to comment https://forums.phpfreaks.com/topic/80242-suggestions/#findComment-406701 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. Link to comment https://forums.phpfreaks.com/topic/80242-suggestions/#findComment-406702 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 Link to comment https://forums.phpfreaks.com/topic/80242-suggestions/#findComment-406705 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. Link to comment https://forums.phpfreaks.com/topic/80242-suggestions/#findComment-406707 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; } Link to comment https://forums.phpfreaks.com/topic/80242-suggestions/#findComment-406709 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. Link to comment https://forums.phpfreaks.com/topic/80242-suggestions/#findComment-406711 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 Link to comment https://forums.phpfreaks.com/topic/80242-suggestions/#findComment-406712 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. Link to comment https://forums.phpfreaks.com/topic/80242-suggestions/#findComment-406713 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.