我试图弄清楚如何更新特定数据库行中的数据,而不是删除然后再次插入另一个查询。有谁知道我该怎么做?
main.php 内容
<body>
<h1>Introduction Box</h1>
<form action="edit.php" method="post">
Title: <input type="text" name="introtitle">
Description: <textarea name="introdescription"></textarea>
<input type="submit">
</form>
</body>
edit.php 内容(现在这只添加表单中的条目)
<?php
// Connnection to MySQL
$connection = mysqli_connect("");
// Check Connection and Display If Error
if (mysqli_connect_errno($connection)) {
echo "Failed to connect to MySQL: " . mysqli_conncet_error();
}
$introduction="INSERT INTO Introduction (Title, Description)
VALUES ('$_POST[introtitle]','$_POST[introdescription]')";
if (!mysqli_query($connection, $introduction) or die(mysql_error()))
{
die('Error: ' . mysqli_error($connection));
}
echo "Record has been updated.";
mysqli_close($connection);
?>
任何帮助将不胜感激!