【发布时间】:2016-05-17 06:16:31
【问题描述】:
我有一些text input,可以像这样编辑一些主题的值:
while($row = mysql_fetch_row($result2))
{
echo "<tr><td>" . $row['ID'] . "</td><td>" . $row['Name'] . "</td><td>" . $row['Status'] .
"</td><td><input type=\"text\" size=\"4\" id=\"editmath[]\" name=\"editwater\" value=" . $row['math'] . ">
</td><td><input type=\"text\" size=\"4\" id=\"editeng[]\" name=\"editfod\" value=" . $row['english'] . ">
</td><td><input type=\"text\" size=\"4\" id=\"editscie[]\" name=\"editmob\" value=" . $row['science'] . ">
}
<Input type="Submit" value=" Next " name="submit_edit">
在 PHP 中我有这个代码:
if (isset($_GET['submit_edit'])) {
$math[] = $_GET['editmath'];
$eng[] = $_GET['editeng'];
$scie[] = $_GET['editscie'];
sql = "UPDATE student SET math = $math, english = $eng, science = $scie";
$query = mysql_query($sql);
}
但是当我尝试print_rmath 和eng 时,他们只保存了最后一行。如何解决这个问题?
Desired Output :
Math English Science
4 3 2
7 8 10
3 5 12
【问题讨论】:
-
name应该在array()而不是id。您需要更改代码。