By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,715 Members | 1,256 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,715 IT Pros & Developers. It's quick & easy.

How to store data from a multiple check box form

P: 2
I have 6 checkbox in my entryform.php. I am supposed to check more than 1 checkbox at a time. How to store multiple value in single column of database?

Latter I also retrieve value from database and EDIT the form
May 25 '10 #1
Share this Question
Share on Google+
1 Reply

P: 424
you could use a loop that creates a string with the values seperated by commas then insert the final string into the database. when you want to retrieve you would use the explode() function to seperate the data into an array by the commas. if you have six boxes i'd use the for loop below so it counts through but you should also check if your $_POST vars are set before add them into your string as you will just make a string that might look like the one below with blanks

$string = data,,data,data,,

Expand|Select|Wrap|Line Numbers
  1. //explode
  2. $array = explode(",",$string);
  4. //loop
  5. for($i=0;$i<7;$i++){
  6. }
May 25 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.