MySQL:  What type for a checkbox

Posted on 2009-04-22
Last Modified: 2012-05-06
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?



    <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>





        <label for="married"> Married </label></td>

    <td align="left"><input name=Married" size="35" maxlength="20" type="checkbox"></td>


Open in new window

Question by:duta
    LVL 21

    Accepted Solution

    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.
    LVL 10

    Assisted Solution

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to dynamically set the form action using jQuery.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now