我正在为我所工作的公司创建一个库存系统,一切都在顺利进行,直到我到达构建表单的部分来更新数据库中的工作表数量。它在这一行给了我一个未定义的索引错误。
$newSheetNum = $_POST['change_stock'];
我已经发出警报,我知道它正在调整paper_id和change_stock值,但它仍然无法处理。这是构建盒子的PHP代码。
$paperID = $row['paper_id'];
$sheetsIn = $row['number_sheets'];
echo "<form id='paper$paperID' name=form$paperID method='POST' action='paperUpdated.php'>";
echo "<div class='paperBlock alignTextCenter'>";
echo "<p style='display:none;'>";
echo $row['company']." ";
echo "<strong> Paper ID:</strong><input name='paperID' value='$paperID'>".$paperID."</input></p>";
echo "<p>" .$row['paper_weight']." ".$row['sheet_size']." ".$row['paper_mill']." ".$row['paper_finish']." " .$row['paper_color']. " ".$row['stock_type']."</p>";
echo "<div class='inStock' style='text-align:center;display:block;'>";
echo "<p>Sheets in stock: <strong class='sheetStock'>".$row['number_sheets']."</strong></p></div>";
echo "<div class='stockEntry'>";
echo "<input name='change_stock' class='changeStock' value='$sheetsIn'/>";
echo "<input type='submit' value='Done' style='width:70px;height:23px;' autofocus />";
echo "</div>";
echo "</div>";
echo "</form>";
以下是更新的updated.php文件:
//Gets values from paperID and changeStock fields
$paperID = $_POST['paperID'];
$newSheetNum = $_POST['change_stock'];
echo "<script>alert('Paper ID: ' + '$paperID' + ' Sheets Entered: ' + '$newSheetNum');</script>";
$query = "UPDATE `paper_availability` SET `number_sheets` = '$newSheetNum' WHERE `paper_availability`.`paper_id` = '$paperID';";
//Executes the SQL query. If successful the records are returned to $result
$result = mysql_query($query)or die("SQL Error " . mysql_error() . "<script>alert ('SQL String: $sql')</script>" );
任何帮助将不胜感激。他们指望我很快就开始运行,我在这里遇到了障碍。 TY提前。
更新:我发现新信息正在更新数据库,但我的updated.php文件中有一些代码正在暂停DOM呈现页面的其余部分。