var a=0;
function _add_more() {
var txt = "<br><input type=\"file\" name=\"item_file[]\"><br><input type=\"text\" name=\"text"+a+"\">";
document.getElementById("dvFile").innerHTML += txt;
alert(a);
a=a+1;
}
I am using multiple file upload and with multiple titles. I am not able to save text in database for title. Can you please tell the correct syntax $_POST["text"], where should i put a that i am increementing.
$insert=mysql_query("insert into image_upload set title='".$_POST["text"]."', image='".$filen."'") or die(mysql_error());
What John Boker said is true.
But you will need to loop through them to insert them into the database.
An easy way would be to make
name=\"text"+a+"\",name=\"text[]\"(like your file upload element),So then you would have an array of titles.
So in PHP:
foreach($_POST["text"] as $title){$insert=mysql_query("insert into image_upload set title='".$title."', image='".$filen."'") or die(mysql_error());
}
Also why not use
's in your JavaScript instead of escaping the"s?You could probably just loop through your titles while you are looping through your uploaded files.