close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Php code for inserting group checkbox data into the database

Thread began 3/16/2011 9:39 am by sandeep.kesarwani423749 | Last modified 11/26/2014 2:50 am by sandeep.kesarwani423749 | 2924 views | 4 replies

Nico

Thank you

Thank you for the code.
I accomplished it another way
Named my database columns for each answer like this
answer_1,answer_2,answer_3

My checkboxes have values 1,2,3 for each option.
So when I save the data in the database i add the checkbox value as a parameter to the column name that it will be saved and I get something like this.

$InsertQuery->bindColumn("answer_".$_POST['optionvalue'][0]."", "i", "".((isset($_POST['optionvalue'][0]))?$_POST['optionvalue'][0]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("answer_".$_POST['optionvalue'][1]."", "i", "".((isset($_POST['optionvalue'][1]))?$_POST['optionvalue'][1]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("answer_".$_POST['optionvalue'][2]."", "i", "".((isset($_POST['optionvalue'][2]))?$_POST['optionvalue'][2]:"") ."", "WA_DEFAULT");



My checkboxes are like this

<input type="checkbox" name="optionvalue[]" id="optionvalue_1" class="optionvalueclass" value="1">
a) first answer</dd>

<input type="checkbox" name="optionvalue[]" id="optionvalue_2" class="optionvalueclass" value="2">
b) second answer</dd>

<input type="checkbox" name="optionvalue[]" class="optionvalueclass" id="optionvalue_3" value="3">
c) third answer


So what it happens when I submit the form, the query adds the data depending on the values of the checkboxes user has checked

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...