表Aにデータを挿入することは可能ですが、同時に表Bのデータを1つの送信ボタンで更新しますか?私はそれらを更新クエリに入れるか、もう1つのクエリを宣言する必要がありますか?私はコードを書く初心者です。誰かがこの問題を解決するのを助けてください。以下は私のページコードです。1つの書式で別の表に挿入して更新する
<?php
include ("supsrwk_epenyenggaraan.php");
?>
<?php
// initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF'] . "?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")) {
$logoutAction.= "&" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) && ($_GET['doLogout'] == "true")) {
// to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "/supsrwk_epenyenggaraan/stafflogin.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
include ("supsrwk_epenyenggaraan.php");
?>
<?php
// initialize the session
if (!isset($_SESSION)) {
session_start();
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction.= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE aduan SET statusAduan=%s WHERE aduanID=%s", GetSQLValueString($_POST['statusAduan'], "text") , GetSQLValueString($_POST['aduanID'], "int"));
mysql_select_db($database_supsrwk_epenyenggaraan, $supsrwk_epenyenggaraan);
$Result1 = mysql_query($updateSQL, $supsrwk_epenyenggaraan) or die(mysql_error());
$updateGoTo = "/supsrwk_epenyenggaraan/rekodDalamProses.php?aduanID=" . $row_aduan['aduanID'] . "";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo.= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo.= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_staff = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_staff = $_SESSION['MM_Username'];
}
mysql_select_db($database_supsrwk_epenyenggaraan, $supsrwk_epenyenggaraan);
$query_staff = sprintf("SELECT * FROM staff WHERE No_KP = %s", GetSQLValueString($colname_staff, "text"));
$staff = mysql_query($query_staff, $supsrwk_epenyenggaraan) or die(mysql_error());
$row_staff = mysql_fetch_assoc($staff);
$totalRows_staff = "-1";
if (isset($_SESSION['MM_Username'])) {
$totalRows_staff = $_SESSION['MM_Username'];
}
mysql_select_db($database_supsrwk_epenyenggaraan, $supsrwk_epenyenggaraan);
$query_staff = sprintf("SELECT * FROM staff WHERE No_KP = %s", GetSQLValueString($colname_staff, "text"));
$staff = mysql_query($query_staff, $supsrwk_epenyenggaraan) or die(mysql_error());
$row_staff = mysql_fetch_assoc($staff);
$totalRows_staff = mysql_num_rows($staff);
$maxRows_aduan = 10;
$pageNum_aduan = 0;
if (isset($_GET['pageNum_aduan'])) {
$pageNum_aduan = $_GET['pageNum_aduan'];
}
$startRow_aduan = $pageNum_aduan * $maxRows_aduan;
mysql_select_db($database_supsrwk_epenyenggaraan, $supsrwk_epenyenggaraan);
$query_aduan = "SELECT * FROM aduan WHERE statusAduan = 'PERMOHONAN'";
$query_limit_aduan = sprintf("%s LIMIT %d, %d", $query_aduan, $startRow_aduan, $maxRows_aduan);
$aduan = mysql_query($query_limit_aduan, $supsrwk_epenyenggaraan) or die(mysql_error());
$row_aduan = mysql_fetch_assoc($aduan);
if (isset($_GET['totalRows_aduan'])) {
$totalRows_aduan = $_GET['totalRows_aduan'];
}
else {
$all_aduan = mysql_query($query_aduan);
$totalRows_aduan = mysql_num_rows($all_aduan);
}
$totalPages_aduan = ceil($totalRows_aduan/$maxRows_aduan) - 1;
...実行されます.php)。 'htmlentities'を使うといくつかの文字に問題が生じるでしょう.2つのエンコーディングは根本的に異なります。 – tadman