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
https://forums.phpfreaks.com/topic/40395-complex-form-question/
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
https://forums.phpfreaks.com/topic/40395-complex-form-question/#findComment-195475
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.