# a variable number of inputs using JAVASCRIPT for PHP to insert MYSQL



## bukaida (Jun 25, 2009)

First let me start out by saying I am a beginner so I apologize in 
advance if what I ask is too fundamental. 

I am accessing a MYSQL database through a web browser and I am 
entering data into data tables using PHP. 

The problem I am facing is that the number of input rows on the web 
page is not fixed and will vary each time. Someone suggested I use 
Javascript and that is why I am here now. 


Here is an example of the rows that I would like to be able to fill : 
Say for 
record 1(Persons living in canada) 
--------------------------------- 
id  name    address 
--------------------------------- 
1   john      canada 
2 Jim canada 
3 smith canada 
------------------------------- 

record 2(Persons living in LA) 
---------------------------------- 
id    name    address 
--------------------------------- 
1     joe          LA 
2   mathew      LA 
------------------------------- 

I have to design an insert form with textbox which will allow me to insert variable number of records in the table(probably giving an option at the begining,to specify how many records). I am using php 4.4 and mysql 5.1. Please help.


----------



## adatapost (Jul 5, 2009)

create a form for each record.


----------



## bukaida (Jul 7, 2009)

adatapost said:


> create a form for each record.



How will you know in advance about your data?


----------



## Power_user_EX (Jul 8, 2009)

plz explain ur problem a bit more.


----------



## asingh (Oct 1, 2009)

Is it a data entry form..or a display form..?? That has to have dynamic rows..??


----------



## lucifer_is_back (Oct 18, 2009)

just make fix the max number of columns in tables for address 
Eg
id
Name
Age
Add1
Add2(Nullable)
Add3(Nullable)
Add4(Nullable)

if a person has more than a single line u can fill it up


----------



## ramprasad (Oct 22, 2009)

Have a drop down box at the beginning of the page to capture the number of records u want to add. 
On the 'OnSelect' or similar function of that Drop down box, associate a JS which will put the 'Input details' (like Name, Country,etc.) required number of times.


----------

