我正在尝试从动态填充的输入文本字段中插入值。我必须采取哪些进一步的步骤?
我的样本表格:
<form action="" method="POST">
<label>Name:</label><input type="text" name="name[]">
<label>Name:</label><input type="text" name="grade[]">
<input type="submit" name="submit">
</form>
我的 insert.php 文件:
$grade = $_POST['grade'];
$name = $_POST['name'];
$count_name = count($_POST['name']);
for($i=0;$i<$count_name ;$i++){
$new_name = $name[$i];
$query = "INSERT INTO test_table (name, grade)VALUES('$new_name','$grade')";
$result = mysql_query($query);
}