tags:

views:

35

answers:

2

I'm having some trouble deciding which approach I should take. I want to allow users to create their own html forms by choosing different form elements (textfields, textareas, lists, ratios, etc) I guess something similar to http://wufoo.com/ but much more basic. Should I use database tables or create files?

For tables I was thinking to create a table for each form element, e.g

TEXTFIELD TABLE

ID

TEXTFIELD_NAME

USER

...

TEXTAREA TABLE

ID

TEXTAREA_NAME

USER

etc for all form elements

and then just query all of them with..

WHERE user=$user

Or should I generate php files on the server for each form created?

+1  A: 

Should I use database tables or create files?

Storing this stuff in a database has the big advantage that you can easily edit them programmatically, and/or populate the user interface used to edit them.

A generated HTML structure you would have to parse first.

So definitely a database.

Pekka
+1  A: 

One approach I used for custom forms on a mobile device was to define a table for field types (eg: text, date, money, custom), a table for form templates (with owner, version, and XML for the template data), and a table for form values (as XML) with a foreign key to the template.

Someone may create a form template with the available field types, and the collected data may be stored for that template, and optionally by template version. If the database supports it, you could query into the XML data to aggregate fields across forms.

For presentation, you could use a fixed style, or transform the template or collected fields however desired.

Steve
Thanks for the info! But wouldn't a database get too clustered. For example just one user might have 40 list items for a list.
Cyber Junkie
Yes, the data comprising each form would be clustered at the row level, although the table could be partitioned if needed. It depends on the size of the forms you expect. A 40 list item isn't too bad, while a mortgage application probably would be.
Steve
I see! Thanks! :)
Cyber Junkie