Take the 2-minute tour ×

I want to create a dynamic number display of texbox, there will be a a textbox and a submit button, then the numeric value of my first textbox shall display also the number of textbox. Which will allow me to input my records in my database. I am using MySQL for my database and how would I insert the records to my table if the first set records of my textbox is not the same as the second (example I input 3 on my first textbox then three textbox shall appear and a submit button, on my second set of records I decided to have 6 on the first textbox then six textbox shall appear in the page) my question again how am I going to do this?

If ever I use array in fetching records and indexing the value of my dynamic textbox, what type of array shall I use to this? How will I going to name the value of my textbox dynamically? and lastly the I wanted the restrictions also that will set the maximum number of textbox.

share|improve this question

1 Answer 1

Ok. Multiple textboxes, let's call them columns. The first record the user enters in each row is the number of columns they require. The submit button would just call a javascript function to create the required amount of columns for that row on the page. This would have the restriction as to how many can be created and the PHP would also ignore extras if the user works out how to cheat it.

Jumping to your last question (because the second question needs this info). You have decided what the maximum number of columns is so the easiest way if that number isn't large would just be to create a table that can satisfy that many columns. Some fields would be NULL on some rows.

It doesn't matter that the number of columns is different when you want to insert because, for each row, you expect up to a certain amount and only deal with the values you are given, those missing are NULL. When you come to output them you only output those that aren't NULL.

The bit about using an array in fetching records and indexing doesn't make sense to me sorry, but I suspect you're fishing for what php database class to use get the data back from the database? I think the trend is mysqli. Personally I use a bespoke one.

share|improve this answer

Your Answer


