Unix Technical Forum

Data Type for Checkbox and OptionButton

This is a discussion on Data Type for Checkbox and OptionButton within the MySQL forums, part of the Database Server Software category; --> Hey I am building my 1st MySQL database and have 2 questions: 1) If I want to have a ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 09:29 AM
Todd Huttenstine
 
Posts: n/a
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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 09:29 AM
J.O. Aho
 
Posts: n/a
Default Re: Data Type for Checkbox and OptionButton

Todd Huttenstine wrote:
> 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?


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


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


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



--

//Aho
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 09:29 AM
Michael Vilain
 
Posts: n/a
Default Re: Data Type for Checkbox and OptionButton

In article <9ixNh.15$tJ2.6@newsfe02.lga>,
"Todd Huttenstine" <todd.huttenstine@charter.net> wrote:

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


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

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


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

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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 09:29 AM
Jerry Stuckle
 
Posts: n/a
Default Re: Data Type for Checkbox and OptionButton

Todd Huttenstine wrote:
> 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
>
>


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.
jstucklex@attglobal.net
==================
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:32 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com