pouncer Posted February 27, 2007 Share Posted February 27, 2007 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! Quote Link to comment Share on other sites More sharing options...
Daleeburg Posted February 27, 2007 Share Posted February 27, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.