Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > PHP > PHP Forum > สอบถามปัญหาครับ เพิ่มรายการรายละเอียดการซ์้อเข้าไม่ได้ครับ


[PHP] สอบถามปัญหาครับ เพิ่มรายการรายละเอียดการซ์้อเข้าไม่ได้ครับ

 
Topic : 120359



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์



หน้ารายละเอียดซ์้อเข้า (Purchase_detail.php) โดยหน้านี้เป็นของ product_id=1 ครับ

u

ส่วนอันนี้คือหน้าเพิ่มรายละเอียดซ์้อเข้าครับ (addpurchase_detail.php)

x

ลองเพิ่มข้อมูลที่ 2 ของรายละเอียดซ์้อเข้า product_id=1 ครับ

z

ส่วนนี้คือปัญหาครับ เพิ่มข้อมูลที่ 2 ไปแล้ว ข้อมูลไม่ยอม show ครับและในฐานข้อมูล purchase_detail
ข้อมูลที่ 2 ตรงproduct_id เป็น 0 เฉยเลยครับ

u

pur_detail_id เป็น PK และ product_id เป็น FK ครับ

ww

code Purchase_detail.php
Code (PHP)
001.  <?php require_once('Connections/MyConnect.php');
002. 
003.mysql_select_db($database_MyConnect, $MyConnect);
004.$pd=intval($_REQUEST['product_id']);
005.$SQL="select
006.    pur_detail_id id,
007.    product_name name,
008.    DATE_FORMAT(pur_detail_date, '%d-%m-%Y') pur_date,
009.    pur_detail_principal pur_princ,
010.    pur_detail_productqty product_qty
011.from
012.purchase_detail INNER JOIN product
013.ON purchase_detail.pur_detail_id = product.product_id
014.WHERE product.product_id=$pd
015.";
016. 
017.$QUERY= mysql_query($SQL) or die ("Error Query [".$SQL."]".mysql_error()); 
018. 
019.$sql .= "ORDER BY `product_id` ASC ";
020. 
021.$sdl .= "$i=1;
022.    while($i<=5) condition";
023.    $i++;
024. ?>
025.<?php
026.if (!isset($_SESSION)) {
027.   session_start();
028.}
029.$MM_authorizedUsers = "";
030.$MM_donotCheckaccess = "true";
031. 
032. 
033.// *** Restrict Access To Page: Grant or deny access to this page
034.function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
035.  // For security, start by assuming the visitor is NOT authorized.
036.  $isValid = False;
037. 
038.  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
039.  // Therefore, we know that a user is NOT logged in if that Session variable is blank.
040.  if (!empty($UserName)) {
041.    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
042.    // Parse the strings into arrays.
043.    $arrUsers = Explode(",", $strUsers);
044.    $arrGroups = Explode(",", $strGroups);
045.    if (in_array($UserName, $arrUsers)) {
046.      $isValid = true;
047.    }
048.    // Or, you may restrict access to only certain users based on their username.
049.    if (in_array($UserGroup, $arrGroups)) {
050.      $isValid = true;
051.    }
052.    if (($strUsers == "") && true) {
053.      $isValid = true;
054.    }
055.  }
056.  return $isValid;
057.}
058. 
059.$MM_restrictGoTo = "admin/index.php";
060.if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
061.  $MM_qsChar = "?";
062.  $MM_referrer = $_SERVER['PHP_SELF'];
063.  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
064.  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
065.  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
066.  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
067.  header("Location: ". $MM_restrictGoTo);
068.  exit;
069.}
070.?>
071.<?php
072.if (!function_exists("GetSQLValueString")) {
073.function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
074.{
075.  if (PHP_VERSION < 6) {
076.    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
077.  }
078. 
079.  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
080. 
081.  switch ($theType) {
082.    case "text":
083.      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
084.      break;   
085.    case "long":
086.    case "int":
087.      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
088.      break;
089.    case "double":
090.      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
091.      break;
092.    case "date":
093.      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
094.      break;
095.    case "defined":
096.      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
097.      break;
098.  }
099.  return $theValue;
100.}
101.}
102. 
103.$maxRows_purchaseset1 = 5;
104.$pageNum_purchaseset1 = 0;
105.if (isset($_GET['pageNum_purchaseset1'])) {
106.  $pageNum_purchaseset1 = $_GET['pageNum_purchaseset1'];
107.}
108.$startRow_purchaseset1 = $pageNum_purchaseset1 * $maxRows_purchaseset1;
109. 
110. 
111.$query_purchaseset1 = "SELECT * FROM purchase_detail";
112.$query_limit_purchaseset1 = sprintf("%s LIMIT %d, %d", $query_purchaseset1, $startRow_purchaseset1, $maxRows_purchaseset1);
113.$purchaseset1 = mysql_query($query_limit_purchaseset1, $MyConnect) or die(mysql_error());
114.$row_purchaseset1 = mysql_fetch_assoc($purchaseset1);
115. 
116.if (isset($_GET['totalRows_purchaseset1'])) {
117.  $totalRows_purchaseset1 = $_GET['totalRows_purchaseset1'];
118.} else {
119.  $all_purchaseset1 = mysql_query($query_purchaseset1);
120.  $totalRows_purchaseset1 = mysql_num_rows($all_purchaseset1);
121.}
122.$totalPages_purchaseset1 = ceil($totalRows_purchaseset1/$maxRows_purchaseset1)-1;
123.?>
124.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
125.<html xmlns="http://www.w3.org/1999/xhtml">
126.<head>
127.<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
128.<title>purchase_detail</title>
129. 
130.<script src="js/jquery.js" type="text/javascript"></script>
131.<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
132.</head>
133.<style type="text/css">
134.#MenuBar1 {
135.    font-size: 230%;
136.    font-family: "Courier New", Courier, monospace;
137.}
138.body p {
139.    font-size: 18px;
140.    text-align: center;
141.    color: #000;
142.}
143.body h2 {
144.    text-align: center;
145.}
146.</style>
147. 
148.<body class='container'>
149.<p><img src="shop.jpg" width="1117" height="149" />
150.</p>
151.<h3>ร้านเกสร
152.</h3>
153.<p>ระบบจัดการฐานข้อมูลสำหรับร้านค้าปลีก</p>
154. 
155.<div class="btn-group">
156.  <button class="btn">ขายสินค้า</button>
157.</div>
158. 
159.<div class="btn-group">
160.  <button class="btn">ข้อมูลพื้นฐาน</button>
161.  <button class="btn dropdown-toggle" data-toggle="dropdown">
162.    <span class="caret"></span>
163.  </button> 
164.  <ul class="dropdown-menu">
165.    <li><a href="Product.php">ข้อมูลสินค้า</a></li>
166.    <li><a href="Category.php">ข้อมูลประเภทสินค้า</a></li>
167.    <li><a href="Supplier.php">ข้อมูลผู้จัดจำหน่าย</a></li>
168.    <!-- dropdown menu links -->
169.  </ul>
170.</div>
171. 
172.<div class="btn-group">
173.  <button class="btn"><a href="Unit.php">หน่วยสินค้า</a></button>
174.</div>
175. 
176.<div class="btn-group">
177.  <button class="btn">จัดการลูกหนี้</button>
178.</div>
179. 
180.<div class="btn-group"
181.  <button class="btn">เพิ่มเติม</button>
182.  <button class="btn dropdown-toggle" data-toggle="dropdown">
183.    <span class="caret"></span>
184.  </button> 
185.  <ul class="dropdown-menu">
186.    <li><a href="#">ดูสินค้าใกล้หมด</a></li>
187.    <li><a href="#">เช็คสต๊อกสินค้า</a></li>
188.    <!-- dropdown menu links -->
189.  </ul>
190.</div>
191. 
192.  <div class="btn-group">
193.  <button class="btn"><a href="edit-profile.php">แก้ไขข้อมูลส่วนตัว</a></button>
194.</div>
195. 
196.  <div class="btn-group">
197.  <button class="btn"><a href="admin/index.php">ออกจากระบบ</a></button>
198.</div>
199.<p>&nbsp;</p>
200.<p>รายละเอียดการซื้อเข้า</p>
201.<p>
202.  <a href="addpurchase_detail.php?product_id=<?php echo $row_purchaseset1['product_id']; ?>">
203.  <input type="submit" name="btn" id="btn" value="เพิ่ม" />
204.</a></p>
205.<table table class="table table-bordered" width="105%" border="1">
206.  <tr class="success">
207.    <td width="196">รหัส</td>
208.    <td width="196">ชื่อสินค้า</td>
209.    <td width="213">วันที่ซื้อเข้า</td>
210.    <td width="238">ราคาต้นทุน</td>
211.    <td width="252">จำนวนสินค้าที่ซื้อเข้า</td>
212.    <td width="55">แก้ไข</td>
213.  </tr>
214.  <?php while($rs=mysql_fetch_array($QUERY))  {      ?>
215.    <tr>
216.      <td><?php echo $rs['id']; ?></td>
217.      <td><?php echo $rs['name']; ?></td>
218.      <td><?php echo $rs['pur_date']; ?></td>
219.      <td><?php echo $rs['pur_princ']; ?></td>
220.      <td><?php echo $rs['product_qty']; ?></td>
221.      <td><i class="icon-pencil"></i><a href="editpurchase_detail.php?pur_detail_id    =<?php echo $rs['pur_detail_id']; ?>">แก้ไข</a></td>
222.    </tr>
223.    <?php } while ($row_purchaseset1 = mysql_fetch_assoc($purchaseset1)); ?>
224.</table>
225.<script src="js/jquery.js"></script>
226.<script src="js/bootstrap.min.js"></script>
227. 
228.</body>
229.</html>
230.<?php
231.mysql_free_result($purchaseset1);
232.?>


code addpurchase_detail.php
Code (PHP)
001.   <?php require_once('Connections/MyConnect.php'); ?>
002.<?php
003.if (!isset($_SESSION)) {
004.  session_start();
005.}
006.$MM_authorizedUsers = "";
007.$MM_donotCheckaccess = "true";
008. 
009.// *** Restrict Access To Page: Grant or deny access to this page
010.function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
011.  // For security, start by assuming the visitor is NOT authorized.
012.  $isValid = False;
013. 
014.  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
015.  // Therefore, we know that a user is NOT logged in if that Session variable is blank.
016.  if (!empty($UserName)) {
017.    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
018.    // Parse the strings into arrays.
019.    $arrUsers = Explode(",", $strUsers);
020.    $arrGroups = Explode(",", $strGroups);
021.    if (in_array($UserName, $arrUsers)) {
022.      $isValid = true;
023.    }
024.    // Or, you may restrict access to only certain users based on their username.
025.    if (in_array($UserGroup, $arrGroups)) {
026.      $isValid = true;
027.    }
028.    if (($strUsers == "") && true) {
029.      $isValid = true;
030.    }
031.  }
032.  return $isValid;
033.}
034. 
035.$MM_restrictGoTo = "admin/index.php";
036.if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
037.  $MM_qsChar = "?";
038.  $MM_referrer = $_SERVER['PHP_SELF'];
039.  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
040.  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
041.  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
042.  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
043.  header("Location: ". $MM_restrictGoTo);
044.  exit;
045.}
046.?>
047.<?php
048.if (!function_exists("GetSQLValueString")) {
049.function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
050.{
051.  if (PHP_VERSION < 6) {
052.    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
053.  }
054. 
055.  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
056. 
057.  switch ($theType) {
058.    case "text":
059.      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
060.      break;   
061.    case "long":
062.    case "int":
063.      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
064.      break;
065.    case "double":
066.      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
067.      break;
068.    case "date":
069.      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
070.      break;
071.    case "defined":
072.      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
073.      break;
074.  }
075.  return $theValue;
076.}
077.}
078. 
079.$editFormAction = $_SERVER['PHP_SELF'];
080.if (isset($_SERVER['QUERY_STRING'])) {
081.  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
082.}
083. 
084.if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
085.  $insertSQL = sprintf("INSERT INTO purchase_detail (pur_detail_date, pur_detail_principal, pur_detail_productqty) VALUES (%s, %s, %s)",
086.                       GetSQLValueString($_POST['pur_detail_date'], "date"),
087.                       GetSQLValueString($_POST['pur_detail_principal'], "double"),
088.                       GetSQLValueString($_POST['pur_detail_productqty'], "int"));
089. 
090.  mysql_select_db($database_MyConnect, $MyConnect);
091.  $Result1 = mysql_query($insertSQL, $MyConnect) or die(mysql_error());
092. 
093.  $insertGoTo = "Purchase_detail.php";
094.  if (isset($_SERVER['QUERY_STRING'])) {
095.    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
096.    $insertGoTo .= $_SERVER['QUERY_STRING'];
097.  }
098.  header(sprintf("Location: %s", $insertGoTo));
099.}
100.?>
101.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
102.<html xmlns="http://www.w3.org/1999/xhtml">
103.<head>
104.<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
105.<title>addpurchase_detail</title>
106.<?php 
107.$jquery_ui_v="1.8.5"
108.$theme=array
109.    "0"=>"base"
110.    "1"=>"black-tie"
111.    "2"=>"blitzer"
112.    "3"=>"cupertino"
113.    "4"=>"dark-hive"
114.    "5"=>"dot-luv"
115.    "6"=>"eggplant"
116.    "7"=>"excite-bike"
117.    "8"=>"flick"
118.    "9"=>"hot-sneaks"
119.    "10"=>"humanity"
120.    "11"=>"le-frog"
121.    "12"=>"mint-choc"
122.    "13"=>"overcast"
123.    "14"=>"pepper-grinder"
124.    "15"=>"redmond"
125.    "16"=>"smoothness"
126.    "17"=>"south-street"
127.    "18"=>"start"
128.    "19"=>"sunny"
129.    "20"=>"swanky-purse"
130.    "21"=>"trontastic"
131.    "22"=>"ui-darkness"
132.    "23"=>"ui-lightness"
133.    "24"=>"vader" 
134.); 
135.$jquery_ui_theme=$theme[22]; 
136.?>
137.<link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/<;?=$jquery_ui_v?>/themes/<?=$jquery_ui_theme?>/jquery-ui.css" />
138.<style type="text/css"
139./* ปรับขนาดตัวอักษรของข้อความใน tabs 
140.สามารถปรับเปลี่ยน รายละเอียดอื่นๆ เพิ่มเติมเกี่ยวกับ tabs
141.*/ 
142..ui-tabs{ 
143.    font-family:tahoma; 
144.    font-size:11px; 
145.
146.</style> 
147.<style type="text/css">
148./* Overide css code กำหนดความกว้างของปฏิทินและอื่นๆ */
149..ui-datepicker{
150.    width:220px;
151.    font-family:tahoma;
152.    font-size:11px;
153.    text-align:center;
154.}
155.</style>
156.   
157.<style type="text/css">
158.#MenuBar1 {
159.    font-size: 230%;
160.    font-family: "Courier New", Courier, monospace;
161.}
162.body p {
163.    font-size: 18px;
164.    text-align: center;
165.    color: #000;
166.}
167.body h2 {
168.    text-align: center;
169.}
170.</style>
171.<script src="js/jquery.js" type="text/javascript"></script>
172.<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
173.</head>
174. 
175.<body class='container'>
176.<p><img src="shop.jpg" width="1117" height="149" />
177.</p>
178.<h3>ร้านเกสร
179.</h3>
180.<p>ระบบจัดการฐานข้อมูลสำหรับร้านค้าปลีก</p>
181. 
182.<div class="btn-group">
183.  <button class="btn">ขายสินค้า</button>
184.</div>
185. 
186.<div class="btn-group">
187.  <button class="btn">ข้อมูลพื้นฐาน</button>
188.  <button class="btn dropdown-toggle" data-toggle="dropdown">
189.    <span class="caret"></span>
190.  </button> 
191.  <ul class="dropdown-menu">
192.    <li><a href="Product.php">ข้อมูลสินค้า</a></li>
193.    <li><a href="Category.php">ข้อมูลประเภทสินค้า</a></li>
194.    <li><a href="Supplier.php">ข้อมูลผู้จัดจำหน่าย</a></li>
195.    <!-- dropdown menu links -->
196.  </ul>
197.</div>
198. 
199.<div class="btn-group">
200.  <button class="btn"><a href="Unit.php">หน่วยสินค้า</a></button>
201.</div>
202. 
203.<div class="btn-group">
204.  <button class="btn">จัดการลูกหนี้</button>
205.</div>
206. 
207.<div class="btn-group"
208.  <button class="btn">เพิ่มเติม</button>
209.  <button class="btn dropdown-toggle" data-toggle="dropdown">
210.    <span class="caret"></span>
211.  </button> 
212.  <ul class="dropdown-menu">
213.    <li><a href="#">ดูสินค้าใกล้หมด</a></li>
214.    <li><a href="#">เช็คสต๊อกสินค้า</a></li>
215.    <!-- dropdown menu links -->
216.  </ul>
217.</div>
218. 
219.  <div class="btn-group">
220.  <button class="btn"><a href="edit-profile.php">แก้ไขข้อมูลส่วนตัว</a></button>
221.</div>
222. 
223.  <div class="btn-group">
224.  <button class="btn"><a href="admin/index.php">ออกจากระบบ</a></button>
225.</div>
226.<p>&nbsp;</p>
227.<script language="javascript">
228.function fncSubmit()
229.{
230.    if(document.form1.pur_detail_date.value == "")
231.    {
232.        alert("กรุณากรอกข้อมูล วัน เดือน ปี");
233.        document.form1.pur_detail_date.focus();
234.        return false;
235.    }
236.               if(document.form1.pur_detail_principal.value == "")
237.    {
238.        alert("กรุณากรอกข้อมูลให้ครบ");
239.        document.form1.pur_detail_principal.focus();
240.        return false;
241.    }
242.               if(document.form1.pur_detail_productqty.value == "")
243.    {
244.        alert("กรุณากรอกข้อมูลให้ครบ");
245.        document.form1.pur_detail_productqty.focus();
246.        return false;
247.    }
248.    document.form1.submit();
249.}
250.</script>
251.<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"onSubmit="JavaScript:return fncSubmit();">
252.  <table align="center">
253.    <tr valign="baseline">
254.      <td nowrap="nowrap" align="right">&nbsp;</td>
255.      <td>เพิ่มรายละเอียดการซื้อเข้า</td>
256.    </tr>
257.    <tr valign="baseline">
258.    <tr valign="baseline">
259.      <td nowrap="nowrap" align="right">วันที่ซื้อเข้า:</td>
260.      <td><input name="pur_detail_date" type="text" id="pur_detail_date" value="" /></td>
261.    </tr>
262.    <tr valign="baseline">
263.      <td nowrap="nowrap" align="right">ราคาต้นทุน:</td>
264.      <td><input type="text" name="pur_detail_principal" onKeyUp="if(isNaN(this.value)){ alert('กรุณากรอกข้อมูลเป็นตัวเลขเท่านั้น'); this.value='';}" size="32" /></td>
265.    </tr>
266.    <tr valign="baseline">
267.      <td nowrap="nowrap" align="right">จำนวนสินค้าที่ซื้อเข้า:</td>
268.      <td><input type="text" name="pur_detail_productqty" onKeyUp="if(isNaN(this.value)){ alert('กรุณากรอกข้อมูลเป็นตัวเลขเท่านั้น'); this.value='';}" size="32" /></td>
269.    </tr>
270.    <tr valign="baseline">
271.      <td nowrap="nowrap" align="right">&nbsp;</td>
272.      <td><input type="submit" value="ตกลง" /> <input type="submit" name="btn" id="btn" value="ยกเลิก" /></td>
273.    </tr>
274.  </table>
275.  <input type="hidden" name="MM_insert" value="form1" />
276.</form>
277.<p>&nbsp;</p>
278.<p>&nbsp;</p>
279. 
280.<script src="js/jquery.js"></script>
281.<script src="js/bootstrap.min.js"></script>
282. 
283.<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
284.<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
285.<script type="text/javascript">
286.$(function(){
287.    var dateBefore=null;
288.    $("#pur_detail_date").datepicker({
289.        dateFormat: 'yy-mm-dd',
290.        showOn: 'button',
292.        buttonImageOnly: false,
293.        dayNamesMin: ['อา', 'จ', 'อ', 'พ', 'พฤ', 'ศ', 'ส'],
294.        monthNamesShort: ['มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม'],
295.        changeMonth: true,
296.        changeYear: true,
297.        beforeShow:function(){ 
298.            if($(this).val()!=""){
299.                var arrayDate=$(this).val().split("-");    
300.                arrayDate[2]=parseInt(arrayDate[2])-543;
301.                $(this).val(arrayDate[0]+"-"+arrayDate[1]+"-"+arrayDate[2]);
302.            }
303.            setTimeout(function(){
304.                $.each($(".ui-datepicker-year option"),function(j,k){
305.                    var textYear=parseInt($(".ui-datepicker-year option").eq(j).val())+543;
306.                    $(".ui-datepicker-year option").eq(j).text(textYear);
307.                });            
308.            },50);
309.        },
310.        onChangeMonthYear: function(){
311.            setTimeout(function(){
312.                $.each($(".ui-datepicker-year option"),function(j,k){
313.                    var textYear=parseInt($(".ui-datepicker-year option").eq(j).val())+543;
314.                    $(".ui-datepicker-year option").eq(j).text(textYear);
315.                });            
316.            },50);     
317.        },
318.        onClose:function(){
319.            if($(this).val()!="" && $(this).val()==dateBefore){        
320.                var arrayDate=dateBefore.split("-");
321.                arrayDate[2]=parseInt(arrayDate[2])+543;
322.                $(this).val(arrayDate[0]+"-"+arrayDate[1]+"-"+arrayDate[2]);   
323.            }      
324.        },
325.        onSelect: function(dateText, inst){
326.            dateBefore=$(this).val();
327.            var arrayDate=dateText.split("-");
328.            arrayDate[2]=parseInt(arrayDate[2])+543;
329.            $(this).val(arrayDate[0]+"-"+arrayDate[1]+"-"+arrayDate[2]);
330.        }  
331. 
332.    });
333.         
334.});
335.</script>
336.</body>
337.</html>


code Product.php
Code (PHP)
001.<?php require_once('Connections/MyConnect.php');
002.   
003.session_start();
004.mysql_select_db($database_MyConnect, $MyConnect);
005.$SQL="SELECT * FROM product
006.LEFT JOIN category ON (product.cate_id=category.cate_id)
007.LEFT JOIN unit ON (product.unit_id=unit.unit_id)";
008.     
009.$QUERY= mysql_query($SQL) or die ("Error Query [".$SQL."]".mysql_error());  
010.     
011.$sql .= "ORDER BY `product_id` ASC ";
012. 
013. ?>      
014.<?php
015.if (!isset($_SESSION)) {
016.  
017.}
018.$MM_authorizedUsers = "";
019.$MM_donotCheckaccess = "true";
020. 
021.// *** Restrict Access To Page: Grant or deny access to this page
022.function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
023.  // For security, start by assuming the visitor is NOT authorized.
024.  $isValid = False;
025. 
026.  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
027.  // Therefore, we know that a user is NOT logged in if that Session variable is blank.
028.  if (!empty($UserName)) {
029.    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
030.    // Parse the strings into arrays.
031.    $arrUsers = Explode(",", $strUsers);
032.    $arrGroups = Explode(",", $strGroups);
033.    if (in_array($UserName, $arrUsers)) {
034.      $isValid = true;
035.    }
036.    // Or, you may restrict access to only certain users based on their username.
037.    if (in_array($UserGroup, $arrGroups)) {
038.      $isValid = true;
039.    }
040.    if (($strUsers == "") && true) {
041.      $isValid = true;
042.    }
043.  }
044.  return $isValid;
045.}
046. 
047.$MM_restrictGoTo = "admin/index.php";
048.if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
049.  $MM_qsChar = "?";
050.  $MM_referrer = $_SERVER['PHP_SELF'];
051.  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
052.  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
053.  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
054.  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
055.  header("Location: ". $MM_restrictGoTo);
056.  exit;
057.}
058.?>
059.<?php
060.if (!function_exists("GetSQLValueString")) {
061.function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
062.{
063.  if (PHP_VERSION < 6) {
064.    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
065.  }
066. 
067.  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
068. 
069.  switch ($theType) {
070.    case "text":
071.      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
072.      break;   
073.    case "long":
074.    case "int":
075.      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
076.      break;
077.    case "double":
078.      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
079.      break;
080.    case "date":
081.      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
082.      break;
083.    case "defined":
084.      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
085.      break;
086.  }
087.  return $theValue;
088.}
089.}
090. 
091.$maxRows_Productset = 5;
092.$pageNum_Productset = 0;
093.if (isset($_GET['pageNum_Productset'])) {
094.  $pageNum_Productset = $_GET['pageNum_Productset'];
095.}
096.$startRow_Productset = $pageNum_Productset * $maxRows_Productset;
097. 
098. 
099.$query_Productset = "SELECT * FROM product";
100.$query_limit_Productset = sprintf("%s LIMIT %d, %d", $query_Productset, $startRow_Productset, $maxRows_Productset);
101.$Productset = mysql_query($query_limit_Productset, $MyConnect) or die(mysql_error());
102.$row_Productset = mysql_fetch_assoc($Productset);
103. 
104.if (isset($_GET['totalRows_Productset'])) {
105.  $totalRows_Productset = $_GET['totalRows_Productset'];
106.} else {
107.  $all_Productset = mysql_query($query_Productset);
108.  $totalRows_Productset = mysql_num_rows($all_Productset);
109.}
110.$totalPages_Productset = ceil($totalRows_Productset/$maxRows_Productset)-1;
111.?>
112.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
113.<html xmlns="http://www.w3.org/1999/xhtml">
114.<head>
115.<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
116.<title>Product</title>
117.<style type="text/css">
118.#MenuBar1 {
119.    font-size: 230%;
120.    font-family: "Courier New", Courier, monospace;
121.}
122.body p {
123.    font-size: 18px;
124.    text-align: center;
125.    color: #000;
126.}
127.body h2 {
128.    text-align: center;
129.}
130.#form1 #word {
131.    text-align: left;
132.}
133.#form1 #btnSearch {
134.    text-align: center;
135.}
136.#form1 {
137.    text-align: center;
138.}
139.</style>
140.<script src="js/jquery.js" type="text/javascript"></script>
141.<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
142.</head>
143. 
144.<body class='container'>
145.<p><img src="shop.jpg" width="1117" height="149" />
146.</p>
147.<h3>ร้านเกสร
148.</h3>
149.<p>ระบบจัดการฐานข้อมูลสำหรับร้านค้าปลีก</p>
150. 
151.<div class="btn-group">
152.  <button class="btn">ขายสินค้า</button>
153.</div>
154. 
155.<div class="btn-group">
156.  <button class="btn">ข้อมูลพื้นฐาน</button>
157.  <button class="btn dropdown-toggle" data-toggle="dropdown">
158.    <span class="caret"></span>
159.  </button> 
160.  <ul class="dropdown-menu">
161.    <li><a href="Product.php">ข้อมูลสินค้า</a></li>
162.    <li><a href="Category.php">ข้อมูลประเภทสินค้า</a></li>
163.    <li><a href="Supplier.php">ข้อมูลผู้จัดจำหน่าย</a></li>
164.    <!-- dropdown menu links -->
165.  </ul>
166.</div>
167. 
168.<div class="btn-group">
169.  <button class="btn"><a href="Unit.php">หน่วยสินค้า</a></button>
170.</div>
171. 
172.<div class="btn-group">
173.  <button class="btn">จัดการลูกหนี้</button>
174.</div>
175. 
176.<div class="btn-group"
177.  <button class="btn">เพิ่มเติม</button>
178.  <button class="btn dropdown-toggle" data-toggle="dropdown">
179.    <span class="caret"></span>
180.  </button> 
181.  <ul class="dropdown-menu">
182.    <li><a href="#">ดูสินค้าใกล้หมด</a></li>
183.    <li><a href="#">เช็คสต๊อกสินค้า</a></li>
184.    <!-- dropdown menu links -->
185.  </ul>
186.</div>
187. 
188.  <div class="btn-group">
189.  <button class="btn"><a href="edit-profile.php">แก้ไขข้อมูลส่วนตัว</a></button>
190.</div>
191. 
192.  <div class="btn-group">
193.  <button class="btn"><a href="admin/index.php">ออกจากระบบ</a></button>
194.</div>
195.<p>&nbsp;</p>
196. 
197.<form id="form1" name="form1" method="post" action="searchproduct.php">
198.  <label for="word">ค้นหา:<i class="icon-zoom-in"></i></label>
199.  <input type="text" name="word" id="word" />
200.  <input type="submit" name="btnSearch" id="btnSearch" value="ค้นหา" />
201.</form>
202.<p>
203.    <a href="insertproduct.php">
204.    <input type="submit" name="btn" id="btn" value="เพิ่มสินค้า" /></a></p>
205.<p>แสดงสินค้า </p>
206.<table class="table table-bordered" width="500" border="1" align="center">
207.  <tr class="success">
208.    <td width="159">รหัสสินค้า</td>
209.    <td width="181">ชื่อสินค้า</td>
210.    <td width="136">ประเภทสินค้า</td>
211.    <td width="132">หน่วยสินค้า</td>
212.    <td width="195">คงเหลือต่ำสุด</td>
213.    <td width="179">ราคา</td>
214.    <td width="27">แก้ไข</td>
215.    <td width="27">ลบ</td>
216.    <td width="27" align="center">เพิ่มเติม</td>
217.   </tr>
218. 
219.    <?php while($rs=mysql_fetch_array($QUERY))  {      ?>
220.    <tr>
221.      <td><?php echo $rs['product_id']; ?></td>
222.      <td><?php echo $rs['product_name']; ?></td>
223.      <td><?php echo $rs['cate_name']; ?></td>
224.      <td><?php echo $rs['unit_name']; ?></td>
225.      <td><?php echo $rs['product_balance']; ?></td>
226.      <td><?php echo $rs['product_price']; ?></td>
227.      <td><i class="icon-pencil"></i><a href="editproduct.php?product_id=<?php echo $rs['product_id']; ?>">แก้ไข</a></td>
228.      <td align="center"><i class="icon-trash"></i><a onclick="return confirm_delete()" href="deleteproduct.php?product_id=<?php echo $rs['product_id'];?>">ลบ</a></td>
229.      <td><i class="icon-asterisk"></i><a href="Purchase_detail.php?product_id=<?php
230. echo $rs['product_id']; ?>">เพิ่มเติม</a></td>
231.    </tr>
232.    <?php } $rs= mysql_fetch_assoc($Productset); ?>
233.</table>
234.<p>
235.  หน้าที่:
236.  <?php
237.for($dw_i=0;$dw_i<=$totalPages_Productset;$dw_i++){
238.    echo '<a href="?pageNum_Productset=',$dw_i,'"class="pageNum">',($dw_i+1),'</a> ';
239.}
240.?>
241.</p>
242.<script src="js/jquery.js"></script>
243.<script src="js/bootstrap.min.js"></script>
244.<script type="text/javascript">
245.function confirm_delete() {
246.  return confirm('ยืนยันการลบข้อมูล !');
247.}
248.</script>
249.<?php
250.mysql_free_result($Productset);
251.?>




Tag : PHP, MySQL, HTML/CSS, JavaScript



ประวัติการแก้ไข
2015-12-06 23:44:04
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-12-06 23:41:26 By : suwidha View : 1245 Reply : 4
 

 

No. 1



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


ตอน insert ลืมใส่ field product_id หรือเปล่าครับ ผมยังไม่เห็นในโค๊ด
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-12-06 23:49:52 By : PlaKriM
 

 

No. 2



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 1 เขียนโดย : PlaKriM เมื่อวันที่ 2015-12-06 23:49:52
รายละเอียดของการตอบ ::
ไม่ได้ใส่ field product_id น่ะครับ



ประวัติการแก้ไข
2015-12-07 00:53:59
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-12-07 00:53:21 By : suwidha
 

 

No. 3



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


ปัญหามันคือ product_id เป้น 0 ไม่ใช่หรอครับ ไม่ insert เข้าไปมันจะมีค่าหรอครับ
หรือผมเข้าใจโจทย์ผิด
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-12-07 18:05:00 By : PlaKriM
 

 

No. 4



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 3 เขียนโดย : PlaKriM เมื่อวันที่ 2015-12-07 18:05:00
รายละเอียดของการตอบ ::
เข้าใจถูกแล้วครับ คือตอนนี้ผมกำลังสังสัยว่าต้อง insert product_id ลงไปในฐานข้อมูลด้วยไหม ถึงค่าจะไม่เป็น 0

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-12-07 19:58:47 By : suwidha
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามปัญหาครับ เพิ่มรายการรายละเอียดการซ์้อเข้าไม่ได้ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่