我有一个更新表单,它使用循环来回显要更新的记录列表。它包括一个文本字段“句子”和一个复选框“可接受”。我的 foreach 努力没有奏效,并且正在吞噬数据列,所以是时候寻求帮助了。先生们,女士们,我该怎么写呢?
谢谢你的帮助。
<?php
if( isset($_POST["Sentences_ID"]) ) {
foreach($_POST['Sentences_ID'] as $key=>$value) {
$updateSQL = sprintf("UPDATE Sentences SET Sentences=%s, Acceptable=%s WHERE Sentences_ID=$value",
GetSQLValueString($_POST['Sentences'], "text"),
GetSQLValueString($_POST['Acceptable'], "text"),
($_POST['Sentences_ID']));
mysql_select_db($database_name, $name);
$Result1 = mysql_query($updateSQL, $name) or die(mysql_error());
}
}
?>
<?php
do {
?>
Sentence:<input type="hidden" name="Sentences_ID[]" id="Sentences_ID[< ?php echo $row_rsCounting['Sentences_Id'];?>]" value="<?php echo $row_rsCounting['Sentences_Id'];?>" />
Acceptable:<input type="checkbox" name="Acceptable" id="Acceptable" value="Acceptable"/></label> |
<input type="text" name="Sentences" id="Sentences" value="< ?php echo $row_rsCounting['Sentences'];?>" size="50" />
<?php
} while ($row_rsCounting = mysql_fetch_assoc($rsCounting));
?>