|
|
|
สอบถามเรื่องการโค็ดในการผลิตสินค้าโดยหัก จำนวนวัตถุดิบ 50 กิโลกรัม ต่อสินค้า1 ชิ้น ครับ |
|
|
|
|
|
|
|
Code (PHP)
<?php require_once('../Connections/MyConnect.php'); ?>
<?php
session_start();
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 = "../User/LoginPage.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO manufacturing (ProductId, `Date`, ProductTotal, Detailedstorage) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['NBuy'], "int"),
GetSQLValueString($_POST['Mdata'], "date"),
GetSQLValueString($_POST['Munittatal'][$i], "int"),
GetSQLValueString($_POST['MDetailedstorage'], "text"));
mysql_select_db($database_MyConnect, $MyConnect);
$Result1 = mysql_query($insertSQL, $MyConnect) or die(mysql_error());
$insertGoTo = "manufacturing.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_MyConnect, $MyConnect);
$query_Recordset1 = "SELECT * FROM manufacturing";
$Recordset1 = mysql_query($query_Recordset1, $MyConnect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
mysql_select_db($database_MyConnect, $MyConnect);
$query_Recordset2 = "SELECT * FROM product";
$Recordset2 = mysql_query($query_Recordset2, $MyConnect) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
mysql_select_db($database_MyConnect, $MyConnect);
$query_Recordset3 = "SELECT * FROM manufacturing";
$Recordset3 = mysql_query($query_Recordset3, $MyConnect) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);
?>
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="1114" height="83" border="1">
<tr>
<th scope="row"> </th>
</tr>
</table>
<table width="1113" height="332" border="1">
<tr>
<th width="167" scope="row"><a href="../User/Master.php">ถอยกลับ</a></th>
<td width="728" rowspan="2"><p>
<label for="NBuy">ชื่อสินค้า</label>
<select name="NBuy" id="NBuy" title="<?php echo $row_Recordset2['ProductName']; ?>">
<?php
do {
?>
<option value="<?php echo $row_Recordset2['ProductId']?>"><?php echo $row_Recordset2['ProductName']?></option>
<?php
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
$rows = mysql_num_rows($Recordset2);
if($rows > 0) {
mysql_data_seek($Recordset2, 0);
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
}
?>
</select>
</p>
<p>
<label for="MTotal">จำนวนทข้าวเปลือกที่สามารถนำมาผลิตได้</label>
<input name="MTotal" type="text" disabled="disabled" id="MTotal" value="<?php echo $row_Recordset1['ProductTotal']; ?>" />
กิโลกรัม </p>
<p id="MData">
<label for="MDATA">วันที่ผลิต</label>
<input name="Mdata" type="text" disabled="disabled" id="Mdata" value="<?php echo date('m/d/y');?>"/>
</p>
<p>
<label for="Munittatal[]">จำนวนที่ต้องการผลิต</label>
<input name="Munittatal[]" type="text" id="Munittatal[]" />
กระสอบ
* 50 กิโลกรัมต่อ 1 กระสอบ</p>
<p>
<label for="MDetailedstorage">วิธีเก็บรักษา</label>
<textarea name="MDetailedstorage" id="MDetailedstorage" cols="45" rows="5"></textarea>
</p>
<p>
<input type="submit" name="btnma" id="btnma" value="ผลิต" />
</p>
<p>
<label for="prdno"></label>
</p>
<p> </p>
<p> </p>
<p> </p></td>
<td width="196" rowspan="2"> </td>
</tr>
<tr>
<th scope="row"><a href="<?php echo $logoutAction ?>">ออกจากระบบ</a></th>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
mysql_free_result($Recordset2);
mysql_free_result($Recordset3);
?>
Tag : PHP, MySQL, HTML
|
|
|
|
|
|
Date :
2017-05-21 16:03:53 |
By :
bassnaruto |
View :
685 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้ติดปัญหาตรงไหนครับ
|
|
|
|
|
Date :
2017-05-23 06:23:35 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
กระบวนการที่ติดปัญหา มันอยู่ส่วนไหนของ code ก็ลองเขียนสูตร หรือ ทดสอบครับ
อย่างนี่ก็ปัญหาเดิมๆ
|
|
|
|
|
Date :
2017-05-24 09:29:59 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|