Jump to content

Recommended Posts

I am using a php mysql database and have 3 checkboxes in my form. I have one column for each checkbox. I want that if a user checks a box, the value that goes into the corresponding colum should be 1 , else 0.  The data type  i selected for the column is BOOL. But how to accomplish the storing of data into the table ?. Been trying for long but no success.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/70830-solved-need-help-regarding-checkboxes/
Share on other sites

I always use ENUM as the Type and '1','0' as the Length/Values. have 0 as the default.

 

Then this on the sql insert:

 

                      GetSQLValueString(isset($_POST['yourfieldname']) ? "true" : "", "defined","1","0"),

 

Hope that helps?

u can try this way

 

define the default database field value as 0 and from check box pass the value this way

 

<input type="checkbox" name="name1" value="1" />
<input type="checkbox" name="name2" value="1" />                    
<input type="checkbox" name="name3" value="1" />

 

abnd write the sql query to insert the value of the checkbox when the it is checked

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.