|
|
|
รบกวนดูโค็ดให้หน่อยครับ พอดีผม Add ข้อมูลของวันหมดอายุสินค้า เข้าไป แต่พอ Add ไป วันมันเป็น 0000/00/00 หมดนะครับ แก้ยังไง |
|
|
|
|
|
|
|
Code (PHP)
<?php require_once('../Connections/MyConnect.php'); ?>
<?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 orderingproduct (ProductId, `date`, ProductTotal, Detailedstorage, DateEXP, Moneytotal) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['NBuy'], "int"),
GetSQLValueString($_POST['Mdata'], "date"),
GetSQLValueString($_POST['txttotal'], "int"),
GetSQLValueString($_POST['MDetailedstorage'], "text"),
GetSQLValueString($_POST['datepicker'], "date"),
GetSQLValueString($_POST['txtMoney'], "double"));
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 product";
$Recordset1 = mysql_query($query_Recordset1, $MyConnect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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 charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>เพิ่มข้อมูลการสั้งซื้อ</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
background-color: #3FC;
}
</style>
</head>
<body>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="1114" height="83" border="1">
<tr>
<th scope="row"><img src="../18641361_10209167883254001_1055824711_o.jpg" width="1366" height="400" /></th>
</tr>
</table>
<table width="1376" height="332" border="1">
<tr>
<th width="167" bgcolor="#FFFFFF" scope="row"><a href="../User/for-admin.php">ถอยกลับ</a></th>
<td rowspan="2" bgcolor="#FFFFFF"><p>
<label for="NBuy">ชื่อสินค้า</label>
<select name="NBuy" id="NBuy" title="<?php echo $row_Recordset2['ProductName']; ?>">
<?php
do {
?>
<option value="<?php echo $row_Recordset1['ProductId']?>"><?php echo $row_Recordset1['ProductName']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select>
</p>
<p id="MData">
<label for="MDATA">วันทีซื้อสินค้า</label>
<input name="Mdata" type="text" id="Mdata" value="<?php echo date('m/d/y');?>" readonly="readonly"/>
</p>
<p>
<label for="txttotal">จำนวนสินค้าที่</label>
ซื้อ
<input type="text" name="txttotal" id="txttotal" />
กระสอบ</p>
<p>วันหมดอายุ :
<input name="datepicker" type="text" id="datepicker" />
</p>
<p>
<label for="MDetailedstorage">วิธีเก็บรักษา</label>
<input name="MDetailedstorage" type="text" id="MDetailedstorage" value="" size="100" />
</p>
<p>
<label for="txtMoney">ราคา</label>
<input type="text" name="txtMoney" id="txtMoney" />
</p>
<p>
<input type="submit" name="btnma" id="btnma" value="ผลิต" />
</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
</tr>
<tr>
<th bgcolor="#FFFFFF" 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);
?>
Tag : PHP, HTML, CSS, JavaScript, XAMPP
|
|
|
|
|
|
Date :
2017-06-02 16:01:21 |
By :
bassnaruto |
View :
803 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo $insertSQL ออกมาดูว่า ตอน insert data วันที่ format date เป็นแบบไหน
|
|
|
|
|
Date :
2017-06-02 17:21:48 |
By :
thesin18598 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ไขปัญหา Notice: Undefined index บน PHP แสดง Error/Message นี้เมื่อ ..
|
|
|
|
|
Date :
2017-06-05 11:09:52 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|