Live Scores
Sport Statistics
Movie Stars
Programming
Multimedia
Mobile
Database
Enterprise
in
Misc
Other
(Entire Site)
How to store checkbox values in a database
Hello,
I don't know the best way of storing checkboxes values in a data base. So I did a quick research and found that it could be stored as numbers:
http://stackoverflow.com/q
uestions/1
352622/sea
rch-friend
ly-
way-to-
store-chec
kbox-value
s-in-mysql
Now suppose I have 7 choices as check boxes.
How do I know how may many were checked and what are they.
or else, Is there a better way to store check boxes values in a data base?
I was thinking to store them in one text field (but all together looks ugly) What do you think?
table name: Hobbies
field 1: usrID
field 2: hoppyType (check box value)
---
Thanks in advance.
Solution: How to store checkbox values in a database
If you already have your field "Hobbies" created, you can just ALTER it for the new checkboxes:
ALTER TABLE Hobbies ADD cycling TINYINT NOT NULL DEFAULT '0';
ALTER TABLE Hobbies ADD photography TINYINT NOT NULL DEFAULT '0';
ALTER TABLE Hobbies ADD bug_collecting TINYINT NOT NULL DEFAULT '0';
etc...
Popular Tags
Tags:
2003
access
address
cannot
cisco
connect
connection
dhcp
DNS
domain
error
how
internet
ip
linksys
network
Networking
ping
pix
port
remote
router
server
switch
vlan
vpn
windows
wireless
xp
Browse All Tags