您好,我有一个记录详细信息的表格,保存记录后我可以使用链接来更新日记。第一个字段是简单的工作引用,第二个字段基本上是其余所有内容,姓名地址等插入日记中的备注字段中,这是我想出的内容,请给我一些指导。
<?php
//record identifier date format 0000-00-00 same as server
$Dt = $_REQUEST['DT'];
// text output for appontment
$A = $_REQUEST['A'];
$B = $_REQUEST['B'];
$C = $_REQUEST['C'];
$D = $_REQUEST['D'];
$E = $_REQUEST['E'];
$F = $_REQUEST['F'];
$G = $_REQUEST['G'];
$H = $_REQUEST['H'];
$I = $_REQUEST['I'];
$J = $_REQUEST['J'];
$K = $_REQUEST['K'];
$L = $_REQUEST['L'];
$M = $_REQUEST['M'];
$N = $_REQUEST['N'];
// field names to reference
$APP = $_REQUEST['P'];
$JD = $_REQUEST['Q'];
// Field content
$JN = $_REQUEST['JID'];
$Desc = $"" . $A . "" . $B . " " . $C . ". " . $D . ", " . $E . " " . $F . " " . $G . " TF " . number_format($H,0, $decimal_point,"") . " " . $I . ", " . $J . " Walls, " . number_format($K,0, $decimal_point,"") . "Beds. " . $J . " " . $K . " boiler, with " . number_format($L,0, $decimal_point,"") . " radiators. notes " . $M . " observations " . $N . "";
?>
<?php
$servername = "localhost:3306";
$username = "xxxdjw";
$password = "xxxxxx";
$dbname = "xxxxx";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE masterdiary SET $APP ='$JN', $JD = '$Desc' WHERE date = '$dt'";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>
或者尝试编写触发器会更容易吗?
最佳答案
建议为此使用触发器
下面给出了示例触发器
创建
插入后触发 blog_after_insert
ON 博客
对于每一行开始
IF NEW.deleted THEN
SET @changetype = 'DELETE';
ELSE
SET @changetype = 'NEW';
END IF;
INSERT INTO audit (blog_id, changetype) VALUES (NEW.id, @changetype);
END$$
关于php - 服务器更新脚本中的多个变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46876577/