我有一个包含两个表的数据库,点和人。作品为出版和编辑。一份出版物可以有多个版本。Point 具有三列:pub(例如,a、t、e)和 edn 9ce、se、ne)。现在 a-ce=2 点,a-se=1 点,t-ce=3 点,t-se=4 点等。这些值被插入到点表中,这就完成了。隔壁桌的人是高管们写一天工作的地方。这有四列:name、pub、edn 和 point。例如,第 1 个人输入了 a-ce,应在他的名字中插入 2 点。如何使用 PHP 从点表中自动计算 pub 和 edn 并在 men 表中插入相应的值?以下代码描述了作品的插入:
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO men (name, pub, edn) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['pub'], "text"),
GetSQLValueString($_POST['edn'], "text"));
mysql_select_db($database_mathcon, $mathcon);
$Result1 = mysql_query($insertSQL, $mathcon) or die(mysql_error());
}