Entering multiple checkbox values to database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
arny2009
Forum Newbie
Posts: 1
Joined: Tue Nov 17, 2009 6:22 am

Entering multiple checkbox values to database

Post by arny2009 »

Hi All,

I need to submit 3 different set of check box values into the database. I have created the 3 sets of checkboxes with 3 different names each set has a particular name e.g. can[],looking[],activities[].
Now I need to use the array values collected from form post.

I need code to help me out on this.

Thanks in advance !!!
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: Entering multiple checkbox values to database

Post by iankent »

I might be missing something, but wouldn't this work?

Code: Select all

$arr = $_POST["looking"];
foreach($arr as $val) {
    // code to insert to db here?
}
alternatively, depending on how your db is setup, you could implode the array to store the values as a single string?
Post Reply