textbook-management-system/基于PHP的教材管理系统/jcfafang1.php

160 lines
5.8 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php require_once('Connections/jc.php'); ?>
<?php require_once('Connections/jc.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO fafang (shijian, lsren, ssbanji, suliang, jcbianhao) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ff'], "text"),
GetSQLValueString($_POST['ls'], "text"),
GetSQLValueString($_POST['ssbj'], "text"),
GetSQLValueString($_POST['sl'], "double"),
GetSQLValueString($_POST['jc'], "text"));
mysql_select_db($database_jc, $jc);
$Result1 = mysql_query($insertSQL, $jc) or die(mysql_error());
$insertGoTo = "cg8.htm";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE fafang SET suliang=%s WHERE jcbianhao=%s",
GetSQLValueString($_POST['hiddenField'], "double"),
GetSQLValueString($_POST['jc'], "text"));
mysql_select_db($database_jc, $jc);
$Result1 = mysql_query($updateSQL, $jc) or die(mysql_error());
$updateGoTo = "cg8.htm";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_Recordset1 = "-1";
if (isset($_GET['jcbianhao'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['jcbianhao'] : addslashes($_GET['jcbianhao']);
}
mysql_select_db($database_jc, $jc);
$query_Recordset1 = sprintf("SELECT * FROM ruku WHERE jcbianhao = %s", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $jc) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$colname_Recordset2 = "-1";
if (isset($_GET['jcbianhao'])) {
$colname_Recordset2 = (get_magic_quotes_gpc()) ? $_GET['jcbianhao'] : addslashes($_GET['jcbianhao']);
}
mysql_select_db($database_jc, $jc);
$query_Recordset2 = sprintf("SELECT (fafang.suliang-1) as fa FROM fafang WHERE jcbianhao = %s", GetSQLValueString($colname_Recordset2, "text"));
$Recordset2 = mysql_query($query_Recordset2, $jc) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><3E>ޱ<EFBFBD><DEB1><EFBFBD><EFBFBD>ĵ<EFBFBD></title>
<style type="text/css">
<!--
.txt {font-size: 12px;
color: #000000;
}
-->
</style>
</head>
<body topmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<?php include("head.php");?>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="txt">
<tr>
<td align="center"><form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
<table width="300" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" class="txt">
<tr>
<td height="20" colspan="2" align="center"><3E>̲ķ<CCB2><C4B7><EFBFBD></td>
</tr>
<tr>
<td width="102" align="right"><3E>̲ı<CCB2><C4B1><EFBFBD>:</td>
<td width="198"><input name="jc" type="text" id="jc" value="<?php echo $row_Recordset1['jcbianhao']; ?>" /></td>
</tr>
<tr>
<td align="right"><3E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>:</td>
<td width="198"><input name="ff" type="text" id="ff" value="<? print(time());?>" /></td>
</tr>
<tr>
<td align="right"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:</td>
<td><input name="ls" type="text" id="ls" /></td>
</tr>
<tr>
<td align="right"><3E><><EFBFBD><EFBFBD><EFBFBD>༶:</td>
<td><input name="ssbj" type="text" id="ssbj" /></td>
</tr>
<tr>
<td align="right"><3E><><EFBFBD><EFBFBD>:</td>
<td><input name="sl" type="text" id="sl" value="1" /></td>
</tr>
</table>
<label>
<input type="submit" name="Submit" value="<22>̲ķ<CCB2><C4B7><EFBFBD>" />
</label>
<label>
<input name="hiddenField" type="hidden" value="<?php echo $row_Recordset2['fa']; ?>" />
</label>
<p>&nbsp;</p>
<input type="hidden" name="MM_insert" value="form1">
<input type="hidden" name="MM_update" value="form1">
</form>
</td>
</tr>
</table>
<?php include("foot.php");?>
</body>
</html>
<?php
mysql_free_result($Recordset1);
mysql_free_result($Recordset2);
?>