Jump to content

complex form question.


pouncer

Recommended Posts

I have a table called 'dvds'

it has fields like: dvd name, description, fav_actor, release_year, etc etc

 

basically its for users to add their favourite dvd's.

 

what I need to do is create a form (by code) based on the fields because admins can add new fieldnames to the dvds table.

 

im thinking i need to loop through the fieldname and create the text boxes on the form for each field, but im a bit unsure.

 

could someone give me any ideas on how to do it? i also need to check each fields type, if it is of type 'TEXT' then i want to add a multi line text box on the form for this field.

 

i really hope someone can show me how to do this, thanks!

Link to comment
Share on other sites

ok here is my overly complicated and probly wrong way of doing it.

 

create a second table that keeps track of the fields in the first.

the table would be like fieldname (varchar) and field type (int)

 

if you use a loop where is has an if else in it you could make it so that you get what you want

 

I am assuming your admins are using a php script to make the new fields, you could have it so that when the field is created, it also creates a second entry in the keeper table fieldname and an integer (1 or zero) so that if it is a text box it is 1 or no text box is a 0 then your loop would have an if else that checks to see if there is a 1 or a 0 and if there is a 1 it makes a textbox if a 0 then it makes a input line.

 

there has to be a much better way to do this, but if worst comes to worst this would work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.