tags:

views:

37

answers:

3

Hi,

i am having a Table named

Attributes

which has

    id form_id label size sequence_no   Type

    1    1      Name 200    1           Text
    2    1      Age  150    2           Number
    3    1     Address 300  3           Textarea
    4    1     Gender   200 4           Dropdown

I am having the doubt how can i keep the Choices of the Field of type "Dropdown" in the Table Eg. For Gender the choices will Male , Female..

Please give me the suggestions...

A: 

edit :

you can add another type to this table call dropdown_choice, and add all the choices of this dropdown to this table, need to keep in another field the master id of this dropdown choice.

Haim Evgi
A: 

Hi. You simply need a child table like this:

id  value_id  sequence_no  label
4   100       1            Male
4   101       2            Female

Note where id = 4 is all the values for the #4 question.

gahooa
Pretty much what i have. I prefer to put an auto_increment id to make updating/deleting easier.
rezzif
A: 

Sounds like you're trying to build an automagic form that is built from a database?

I would suggest having that table be something like elements and have another table for options which links back to the original id

i.e.

options
id    element_id   value    text
1      4            1       Male
2      4            2       Female

That way for specific types you will be know to look up the options.

You may want another field to specify if its a multiselect or perhaps you could make it another Type.

rezzif