Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
multiple values in single field
Old 01-30-2010, 05:28 PM multiple values in single field
Junior Talker

Posts: 4
Name: phill
Trades: 0
i have a questionnaire im creating in dreamweaver, now on one of hte questions they have the option to select more than one box. e.g days of the week how can i get that to be stored in the databae im using under a particualr field if that makes sense. e.gfield 1 will store monday,tuesday,thursday. etc

hope you can help
pbaker is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-30-2010, 05:58 PM Re: multiple values in single field
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
A Select box with the multiple attribute set.

Or check boxes
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-30-2010, 06:49 PM Re: multiple values in single field
Junior Talker

Posts: 4
Name: phill
Trades: 0
these are checkboxes.
pbaker is offline
Reply With Quote
View Public Profile
 
Old 01-30-2010, 06:59 PM Re: multiple values in single field
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
So what actually is your question?

The server code?

A database structure?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 01-30-2010 at 07:01 PM..
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-31-2010, 04:58 AM Re: multiple values in single field
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
There are many possible solutions. You could have one field for each day in the database, or you could have one field and use a special structure to represent each day. You could i.e. use a 7 digit char field where 0 means that day is excluded and 1 means it's included.

So '0000000' would mean no days were selected, '1111111' means all days were selected and '0000011' means only weekend (if first digit mean monday).
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 01-31-2010, 05:44 AM Re: multiple values in single field
Junior Talker

Posts: 4
Name: phill
Trades: 0
what im meaning is when the data is stored to the database the field will show that the following has been selected: monday,tuesday,wednesday,friday

so basically all the boxes that the user has ticked for that question are keeped in a single field rather than several.

hope this makes a litltle more sense.
pbaker is offline
Reply With Quote
View Public Profile
 
Old 01-31-2010, 06:05 AM Re: multiple values in single field
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
A single field is NOT a good idea for such a scenario. Yes it will be simple to implement BUT it WILL create problems at later stages.

What if someone asks for "all records" for "Friday" it means your search routine is going to have to do some manipulation (slow) on a column to extract those records.

Use a separate table with a PK - FK relationship.

EG:
user/record ID as the linking column and a daynumber column

and just run a JOIN query.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-31-2010, 08:29 AM Re: multiple values in single field
Junior Talker

Posts: 4
Name: phill
Trades: 0
ok i will try what you suggested once the questionnaire has been completed the only thing that will be happening later on is i will export ther results to a CSV later on so they can see whats been filled in. There wont be any other things done with it.
pbaker is offline
Reply With Quote
View Public Profile
 
Old 01-31-2010, 11:38 AM Re: multiple values in single field
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It would be nice just once in a while to get ALL the relevant information at one go, so we could give the best possible answer.

If it is a "one shot" data collection with no sorting needed just store all the data in a single field as a CSV.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to multiple values in single field
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.32586 seconds with 12 queries