• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

MySQL: What type for a checkbox

Hi experts:

I have an abbreviated HTML form as below to get your input which I want to go into a MySQL table.
two attributes below ( (1)  aboutYou (2)  married ) in a MySQL table?

May I use varchar for aboutYou and bool for married?

If I use bool for married, I have to do some more setting in the table?

Thanks!
<FORM>
 
<tr>
    <td align="left" valign="top"><label for="aboutYou"> Description </label></td>
    <td align="left"><TEXTAREA name="aboutYou" cols="27" rows="6" id = "aboutYou"></TEXTAREA></td>
  </tr>
 
 </FORM>
  <tr>
    <td>
        <label for="married"> Married </label></td>
    <td align="left"><input name=Married" size="35" maxlength="20" type="checkbox"></td>
  </tr>

Open in new window

0
duta
Asked:
duta
2 Solutions
 
K VDatabase ConsultantCommented:
yes bool will do, even int(1) will do. Its on how you interpret it.
If you have more than one values like : 'single', 'commited'... you may use an ENUM.
0
 
mstrelanCommented:
problem with TEXTAREA is that it allows unlimited amount of text... so varchar might truncate some if your users paste too much. You might be better off using TEXT instead of VARCHAR... or indicate in some way the max length of a textarea... eg with a character counter like on twitter.

and i generally use tinyint for checkboxes.... and store 0 or 1
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now