对于管理面板,我为每一行制作了一个带有删除、编辑和添加选项的表格,除了执行更新查询之外,一切都运行良好,直到现在已经显示要以其形式编辑的文本,并将编辑值传递给我已通过使用 echo() 验证的下一页。我的代码如下 update.php
<head>
<?php
// 1. Create a database connection
// 2. Select a database to use
include('connect.php');
?>
<?php
// 3. Perform database query
$id=$_SESSION['id'];
$author=$_GET['author'];
$quotation=$_GET['quote'];
//below code is to check
echo $id . "<br>". $author . "<br>". $quotation ."<br>";
//4. update query
$query = "UPDATE 'quotations' SET
'author' = '$author',
'quotation' = '$quotation',
WHERE 'id' = '$id'";
mysql_query($query);
// test to see if the update occurred
if (mysql_affected_rows() == 1) {
// Success!
echo "The page was successfully updated.";
} else {
echo "The page could not be updated.";
}
?>
<?php
// 5. Close connection
mysql_close($connection);
session_destroy();
//header("Location: Admin.php"); commented just to observe the output.
?>
</body>
</html>
通过查询前的回显,我得到了我的编辑值,这意味着表单没有问题,即使连接了数据库但没有更新。在这方面的任何建议将不胜感激。