i am using the php to get all the values from textbox, inside a loop i am getting the values.
inside a loop i also have the insert statement and the count.
The flow is: i will select the value from drop-down list, when i select the number from the drop down list, the corresponding number of text-boxes will be created.
for ex:- i have selected the number 3 from drop-down list. so it will create 3 text-boxes.
now i will enter data into those 3 text-boxes and click submit. when i click submit only the value of last text-box is getting inserted into database.
i.e. when i select 3 and enter data to 3 text-box it is inserting only 3rd text-box value 3 times, instead of inserting 1st,2nd and 3rd value..
how can i solve it..?
here is code i have used..
php:
<?php
mysql_connect("localhost", "tiger", "tiger") or die(mysql_error());
mysql_select_db("theaterdb") or die(mysql_error());
for ($i=0; $i < $_POST["range"] ; $i++)
{
$query = mysql_query("INSERT INTO movie (movie_name,language) VALUES('$_POST[Fname]','$_POST[language]') ") or die(mysql_error());
}
?>
range is a value what i have selected in dropdown.
javascript code:
for(i = 0; i < param; i += 1) {
target.innerHTML +='</br>';
target.innerHTML +='New Movie '+i+' ';
target.innerHTML += '<input type="text" name="Fname">';
}
this is generating the textbox dynamically