变量是$ingval1
等等.. SQL 字段是相同的,显然没有 $..
我的脚本的这一部分没有更新表格,为什么?
<?php // post
$basename1 = 'ingval';$basename2 = 'ingamt';
$basename3 = 'ingdes';$basename4 = 'ingcode';
for ($y = 1; $y < 26; $y++) {
$tempname1 = $basename1 . $y; $tempname2 = $basename2 . $y;
$tempname3 = $basename3 . $y; $tempname4 = $basename4 . $y;
$$tempname1 = $_POST['ingval'.$y];
$$tempname2 = $_POST['ingamt'.$y];
$$tempname3 = $_POST['ingdes'.$y];
$$tempname4 = $_POST['ingcode'.$y];
} // sql insert
$basename1 = 'ingval';$basename2 = 'ingamt';
$basename3 = 'ingdes';$basename4 = 'ingcode';
for ($y = 1; $y < 26; $y++) {
$tempname1 = $basename1 . $y; $tempname2 = $basename2 . $y;
$tempname3 = $basename3 . $y; $tempname4 = $basename4 . $y;
$sql = "UPDATE $cookbookdb SET
ingval.$y = '" . $$tempname1 . "',
ingamt.$y = '" . $$tempname2 . "',
ingdes.$y = '" . $$tempname3 . "',
ingcode.$y = '" . $$tempname4 . "'
WHERE id = '" . $barcodeinput . "'";
sql_query($sql)or die(mysql_error());
} ?>
我已经尝试了几种不同的方法,但仍然没有运气。