Jump to content

[SOLVED] Need help regarding checkboxes


rooney

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.