Professional Web Applications Themes

Data Type for Checkbox and OptionButton - MySQL

Hey I am building my 1st MySQL database and have 2 questions: 1) If I want to have a checkbox linked to a field in a table, what Data Type do I set for that field? 2) If I want to have 2 optionbuttons linked to 2 seperate fields in a table, what Data Type do I set for those fields? Thanks Todd...

  1. #1

    Default Data Type for Checkbox and OptionButton

    Hey

    I am building my 1st MySQL database and have 2 questions:

    1) If I want to have a checkbox linked to a field in a table, what Data Type
    do I set for that field?

    2) If I want to have 2 optionbuttons linked to 2 seperate fields in a table,
    what Data Type do I set for those fields?



    Thanks
    Todd


    Todd Guest

  2. #2

    Default Re: Data Type for Checkbox and OptionButton

    Todd Huttenstine wrote: 

    TINYINT should be okey, use 0 for unchecked and 1 for checked (makes it easier
    in if-statements).

     

    TINYINT should be okey, use 0 for unselected and 1 for selcted option (makes
    it easier in if-statements).



    --

    //Aho
    J.O. Guest

  3. #3

    Default Re: Data Type for Checkbox and OptionButton

    In article <9ixNh.15$lga>,
    "Todd Huttenstine" <net> wrote:
     

    I've used TINYINT. It's set to 1 if the box is checked and 0 if it's
    not.
     

    What are "option buttons"? What's the HTML that's being used to create
    them?

    --
    DeeDee, don't press that button! DeeDee! NO! Dee...



    Michael Guest

  4. #4

    Default Re: Data Type for Checkbox and OptionButton

    Todd Huttenstine wrote: 

    Actually, it's irrelevant.

    You want to check/uncheck the box based on some condition. That is that
    condition? It might be true or false (1 or 0), in which case a tinyint
    would do.

    However, it may some completely different condition. For instance, if
    you're building a bulletin board system, you might want to allow or
    disallow the user access to one or more topics on the board. In this
    case you wouldn't even have a column for that checkbox. You would have
    a link table which has userid's and topicid's. If the userid/topicid
    pair is in the table, the checkbox would be checked. If it isn't in the
    table, the checkbox would be unchecked.

    IOW - don't get hung up on checkboxes. The display of the information
    should be is independent of the storage of the information. What you
    need to do is determine what the column needs to hold based on how it
    will be used in the rest of the program. After all, a column to just
    check/uncheck a box and do nothing else is worthless.

    Base the type of data for that column (or even the presence/absence of
    the column) on the logic in your code and what you need to store there.
    Then determine in your language of choice how to check/uncheck the box
    based on the actual data conditions.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    net
    ==================
    Jerry Guest

Similar Threads

  1. CheckBox data via xmlConnector
    By Tomppalonen in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: April 25th, 05:59 AM
  2. Converting from data type varchar to data type money
    By schaudry in forum Coldfusion - Advanced Techniques
    Replies: 6
    Last Post: June 10th, 11:01 PM
  3. Converting data type varchar to data type money
    By schaudry in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: June 10th, 07:22 PM
  4. Checkbox - Data
    By The Corinthian in forum ASP Components
    Replies: 1
    Last Post: October 13th, 05:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139