|
|
|
อยากทราบวิธีการดัก textbox แบบ วนลูป ไม่ทราบว่าใครพอแก้เป็นมั้งช่วยดูหนอ่ยนะคาบ |
|
|
|
|
|
|
|
เป็น code ตัวเต็มคาบ คือยังไม่ได้อะครับ ถ้าtxtitem ที่วางไว้ไม่ได้ระบุจำนวนที่แน่นอนตาม hdline อะครับ จะต้องทำยังไง
Code (PHP)
<?php require_once('Connections/otop.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "member_login_error.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?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;
}
}
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p1 = "SELECT * FROM webconfig WHERE web_conf_id = 5";
$rs_m_s_p1 = mysql_query($query_rs_m_s_p1, $otop) or die(mysql_error());
$row_rs_m_s_p1 = mysql_fetch_assoc($rs_m_s_p1);
$totalRows_rs_m_s_p1 = mysql_num_rows($rs_m_s_p1);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p2 = "SELECT * FROM webconfig WHERE web_conf_id = 4";
$rs_m_s_p2 = mysql_query($query_rs_m_s_p2, $otop) or die(mysql_error());
$row_rs_m_s_p2 = mysql_fetch_assoc($rs_m_s_p2);
$totalRows_rs_m_s_p2 = mysql_num_rows($rs_m_s_p2);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p3 = "SELECT * FROM webconfig WHERE web_conf_id = 6";
$rs_m_s_p3 = mysql_query($query_rs_m_s_p3, $otop) or die(mysql_error());
$row_rs_m_s_p3 = mysql_fetch_assoc($rs_m_s_p3);
$totalRows_rs_m_s_p3 = mysql_num_rows($rs_m_s_p3);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p4 = "SELECT * FROM webconfig WHERE web_conf_id = 7";
$rs_m_s_p4 = mysql_query($query_rs_m_s_p4, $otop) or die(mysql_error());
$row_rs_m_s_p4 = mysql_fetch_assoc($rs_m_s_p4);
$totalRows_rs_m_s_p4 = mysql_num_rows($rs_m_s_p4);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p5 = "SELECT * FROM webconfig WHERE web_conf_id = 8";
$rs_m_s_p5 = mysql_query($query_rs_m_s_p5, $otop) or die(mysql_error());
$row_rs_m_s_p5 = mysql_fetch_assoc($rs_m_s_p5);
$totalRows_rs_m_s_p5 = mysql_num_rows($rs_m_s_p5);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p6 = "SELECT * FROM webconfig WHERE web_conf_id = 9";
$rs_m_s_p6 = mysql_query($query_rs_m_s_p6, $otop) or die(mysql_error());
$row_rs_m_s_p6 = mysql_fetch_assoc($rs_m_s_p6);
$totalRows_rs_m_s_p6 = mysql_num_rows($rs_m_s_p6);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p7 = "SELECT * FROM webconfig WHERE web_conf_id = 10";
$rs_m_s_p7 = mysql_query($query_rs_m_s_p7, $otop) or die(mysql_error());
$row_rs_m_s_p7 = mysql_fetch_assoc($rs_m_s_p7);
$totalRows_rs_m_s_p7 = mysql_num_rows($rs_m_s_p7);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p8 = "SELECT * FROM webconfig WHERE web_conf_id = 21";
$rs_m_s_p8 = mysql_query($query_rs_m_s_p8, $otop) or die(mysql_error());
$row_rs_m_s_p8 = mysql_fetch_assoc($rs_m_s_p8);
$totalRows_rs_m_s_p8 = mysql_num_rows($rs_m_s_p8);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p9 = "SELECT * FROM webconfig WHERE web_conf_id = 16";
$rs_m_s_p9 = mysql_query($query_rs_m_s_p9, $otop) or die(mysql_error());
$row_rs_m_s_p9 = mysql_fetch_assoc($rs_m_s_p9);
$totalRows_rs_m_s_p9 = mysql_num_rows($rs_m_s_p9);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p10 = "SELECT * FROM webconfig WHERE web_conf_id = 17";
$rs_m_s_p10 = mysql_query($query_rs_m_s_p10, $otop) or die(mysql_error());
$row_rs_m_s_p10 = mysql_fetch_assoc($rs_m_s_p10);
$totalRows_rs_m_s_p10 = mysql_num_rows($rs_m_s_p10);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p11 = "SELECT * FROM webconfig WHERE web_conf_id = 18";
$rs_m_s_p11 = mysql_query($query_rs_m_s_p11, $otop) or die(mysql_error());
$row_rs_m_s_p11 = mysql_fetch_assoc($rs_m_s_p11);
$totalRows_rs_m_s_p11 = mysql_num_rows($rs_m_s_p11);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p12 = "SELECT * FROM webconfig WHERE web_conf_id = 19";
$rs_m_s_p12 = mysql_query($query_rs_m_s_p12, $otop) or die(mysql_error());
$row_rs_m_s_p12 = mysql_fetch_assoc($rs_m_s_p12);
$totalRows_rs_m_s_p12 = mysql_num_rows($rs_m_s_p12);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p13 = "SELECT * FROM webconfig WHERE web_conf_id = 15";
$rs_m_s_p13 = mysql_query($query_rs_m_s_p13, $otop) or die(mysql_error());
$row_rs_m_s_p13 = mysql_fetch_assoc($rs_m_s_p13);
$totalRows_rs_m_s_p13 = mysql_num_rows($rs_m_s_p13);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p14 = "SELECT * FROM webconfig WHERE web_conf_id = 20";
$rs_m_s_p14 = mysql_query($query_rs_m_s_p14, $otop) or die(mysql_error());
$row_rs_m_s_p14 = mysql_fetch_assoc($rs_m_s_p14);
$totalRows_rs_m_s_p14 = mysql_num_rows($rs_m_s_p14);
mysql_select_db($database_otop, $otop);
$query_rs_title = "SELECT * FROM webconfig WHERE web_conf_id = 22";
$rs_title = mysql_query($query_rs_title, $otop) or die(mysql_error());
$row_rs_title = mysql_fetch_assoc($rs_title);
$totalRows_rs_title = mysql_num_rows($rs_title);
mysql_select_db($database_otop, $otop);
$query_rs_background = "SELECT * FROM webconfig WHERE web_conf_id = 23";
$rs_background = mysql_query($query_rs_background, $otop) or die(mysql_error());
$row_rs_background = mysql_fetch_assoc($rs_background);
$totalRows_rs_background = mysql_num_rows($rs_background);
mysql_select_db($database_otop, $otop);
$query_rs_bgtitle = "SELECT * FROM webconfig WHERE web_conf_id = 24";
$rs_bgtitle = mysql_query($query_rs_bgtitle, $otop) or die(mysql_error());
$row_rs_bgtitle = mysql_fetch_assoc($rs_bgtitle);
$totalRows_rs_bgtitle = mysql_num_rows($rs_bgtitle);
mysql_select_db($database_otop, $otop);
$query_rs_bgdetail = "SELECT * FROM webconfig WHERE web_conf_id = 25";
$rs_bgdetail = mysql_query($query_rs_bgdetail, $otop) or die(mysql_error());
$row_rs_bgdetail = mysql_fetch_assoc($rs_bgdetail);
$totalRows_rs_bgdetail = mysql_num_rows($rs_bgdetail);
mysql_select_db($database_otop, $otop);
$query_rs_bgdown = "SELECT * FROM webconfig WHERE web_conf_id = 26";
$rs_bgdown = mysql_query($query_rs_bgdown, $otop) or die(mysql_error());
$row_rs_bgdown = mysql_fetch_assoc($rs_bgdown);
$totalRows_rs_bgdown = mysql_num_rows($rs_bgdown);
//============================================================================
// ถ้าเป็นการเลือกรายการสินค้าเป็นรายการแรก ให้สร้าง cart ใหม่
//echo $_SESSION['newcart'];
if ($_SESSION['newcart'] == 0) {
// เพิ่มข้อมูลรายการ cart ใหม่
$cdate = (date('Y')+543);
$cartdate = date("$cdate-m-d");
$insertSQL = "INSERT INTO cart (cart_date, mb_id) VALUES ('" . $cartdate . "', '" .$_SESSION['mb_id']. "')";
mysql_select_db($database_otop, $otop);
$Result1 = mysql_query($insertSQL, $otop) or die(mysql_error());
$_SESSION['newcart'] = 1;
// เลือก tb cart โดยเลือกเฉพาะรายการของลูกค้าคนปัจจุบัน เรียงตาม id จากมากไปหาน้อย ไปหาค่า cart_id
mysql_select_db($database_otop, $otop);
$query_rs_cart = "SELECT * FROM cart WHERE mb_id = '" . $_SESSION['mb_id'] . "' ORDER BY cart_id DESC";
$rs_cart = mysql_query($query_rs_cart, $otop) or die(mysql_error());
$row_rs_cart = mysql_fetch_assoc($rs_cart);
$_SESSION['cartID'] = $row_rs_cart['cart_id'];
$status = $row_rs_cart['status'];
}
//ชุดที่ 2
if ($_GET['id'] != "") { //=========ตัวรับค่า
//ตรวจสอบดูว่ามีรายการข้อมูลซ้ำหรือไม
mysql_select_db($database_otop, $otop);
$query_rs_chkcart = "SELECT * FROM cart_detail WHERE pd_id = '" . $_GET['id'] . "' and cart_id = '". $_SESSION['cartID'] . "'";
$rs_chkcart = mysql_query($query_rs_chkcart, $otop) or die(mysql_error());
$row_rs_chkcart = mysql_fetch_assoc($rs_chkcart);
$totalRows_rs_chkcart = mysql_num_rows($rs_chkcart);
//ถ้าพบว่ามีข้อมูลไม่มีข้อมูลซ้ำ
if ($totalRows_rs_chkcart == 0) {
// เพิ่มรายการสินค้าที่เลือกลงใน db
$insertSQL = "INSERT INTO cart_detail (cart_id, pd_id, item) VALUES ('" . $_SESSION['cartID'] . "', '". $_GET['id'] . "', '1')";
//print "==========================";
} else {
// ถ้ามีข้อมูลซ้ำ ก็ให้เพิ่มจำนวนเข้าไป
$additem = $row_rs_chkcart['item']+1;
$insertSQL = "UPDATE cart_detail SET item='" . $additem . "' WHERE pd_id='" . $_GET['id'] . "' and cart_id='" . $_SESSION['cartID'] ."'";
}
mysql_select_db($database_otop, $otop);
$Result1 = mysql_query($insertSQL, $otop) or die(mysql_error());
//เรียกหน้านี้ใหม่ โดยไม่ให้มีค่า $_GET['product_id']
//header("Location: " . "takeorder_test.php");
}
$colname_rs_cart = "-1";
if (isset($_GET['id'])) {
$colname_rs_cart = $_GET['id'];
}
mysql_select_db($database_otop, $otop);
$query_rs_cart = sprintf("SELECT * FROM cart WHERE cart_id = %s", GetSQLValueString($colname_rs_cart, "int"));
$rs_cart = mysql_query($query_rs_cart, $otop) or die(mysql_error());
$row_rs_cart = mysql_fetch_assoc($rs_cart);
$totalRows_rs_cart = mysql_num_rows($rs_cart);
$colname_rs_cart_detail = "-1";
if (isset($_SESSION['cartID'])) {
$colname_rs_cart_detail = $_SESSION['cartID'];
}
mysql_select_db($database_otop, $otop);
$query_rs_cart_detail = sprintf("SELECT * FROM cart_detail INNER JOIN product ON (cart_detail.pd_id = product.pd_id) WHERE cart_detail.cart_id = %s ORDER BY cart_detail.cart_detail_id ASC", GetSQLValueString($colname_rs_cart_detail, "int"));
$rs_cart_detail = mysql_query($query_rs_cart_detail, $otop) or die(mysql_error());
$row_rs_cart_detail = mysql_fetch_assoc($rs_cart_detail);
$totalRows_rs_cart_detail = mysql_num_rows($rs_cart_detail);
mysql_select_db($database_otop, $otop);
$query_rs_chkcart = "SELECT * FROM cart_detail WHERE pd_id = '" . $_GET['id'] . "' and cart_id = '". $_SESSION['cartID'] . "'";
$rs_chkcart = mysql_query($query_rs_chkcart, $otop) or die(mysql_error());
$row_rs_chkcart = mysql_fetch_assoc($rs_chkcart);
$totalRows_rs_chkcart = mysql_num_rows($rs_chkcart);
$colname_rs_member1 = "-1";
if (isset($_SESSION['member_id'])) {
$colname_rs_member1 = $_SESSION['member_id'];
}
mysql_select_db($database_otop, $otop);
$query_rs_member1 = sprintf("SELECT * FROM member WHERE mb_id = %s", GetSQLValueString($colname_rs_member1, "int"));
$rs_member1 = mysql_query($query_rs_member1, $otop) or die(mysql_error());
$row_rs_member1 = mysql_fetch_assoc($rs_member1);
$totalRows_rs_member1 = mysql_num_rows($rs_member1);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p15 = "SELECT * FROM webconfig WHERE web_conf_id = 48";
$rs_m_s_p15 = mysql_query($query_rs_m_s_p15, $otop) or die(mysql_error());
$row_rs_m_s_p15 = mysql_fetch_assoc($rs_m_s_p15);
$totalRows_rs_m_s_p15 = mysql_num_rows($rs_m_s_p15);
mysql_select_db($database_otop, $otop);
$query_rs_m_s_p16 = "SELECT * FROM webconfig WHERE web_conf_id = 49";
$rs_m_s_p16 = mysql_query($query_rs_m_s_p16, $otop) or die(mysql_error());
$row_rs_m_s_p16 = mysql_fetch_assoc($rs_m_s_p16);
$totalRows_rs_m_s_p16 = mysql_num_rows($rs_m_s_p16);
mysql_select_db($database_otop, $otop);
$query_rs_color_title = "SELECT * FROM color WHERE cl_id = 10";
$rs_color_title = mysql_query($query_rs_color_title, $otop) or die(mysql_error());
$row_rs_color_title = mysql_fetch_assoc($rs_color_title);
$totalRows_rs_color_title = mysql_num_rows($rs_color_title);
mysql_select_db($database_otop, $otop);
$query_rs_color_list = "SELECT * FROM color WHERE cl_id = 2";
$rs_color_list = mysql_query($query_rs_color_list, $otop) or die(mysql_error());
$row_rs_color_list = mysql_fetch_assoc($rs_color_list);
$totalRows_rs_color_list = mysql_num_rows($rs_color_list);
mysql_select_db($database_otop, $otop);
$query_rs_color_note = "SELECT * FROM color WHERE cl_id = 1";
$rs_color_note = mysql_query($query_rs_color_note, $otop) or die(mysql_error());
$row_rs_color_note = mysql_fetch_assoc($rs_color_note);
$totalRows_rs_color_note = mysql_num_rows($rs_color_note);
mysql_select_db($database_otop, $otop);
$query_rs_vat = "SELECT * FROM vat";
$rs_vat = mysql_query($query_rs_vat, $otop) or die(mysql_error());
$row_rs_vat = mysql_fetch_assoc($rs_vat);
$totalRows_rs_vat = mysql_num_rows($rs_vat);
mysql_select_db($database_otop, $otop);
$query_rs_bgppt1 = "SELECT * FROM webconfig WHERE web_conf_id = 55";
$rs_bgppt1 = mysql_query($query_rs_bgppt1, $otop) or die(mysql_error());
$row_rs_bgppt1 = mysql_fetch_assoc($rs_bgppt1);
$totalRows_rs_bgppt1 = mysql_num_rows($rs_bgppt1);
?>
<!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><?php echo $row_rs_title['web_conf_desc']; ?></title>
<style type="text/css">
<!--
body {
background-image: url(<?php echo $row_rs_background['web_conf_desc']; ?>);
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style3 { font-family: Tahoma, "MS Sans Serif", "Cordia New";
font-size: 14px;
color: <?php echo $row_rs_color_list['cl_code']; ?>;
}
.style33 { font-family: Tahoma, "MS Sans Serif", "Cordia New";
font-size: 14px;
color: #FFFFFF;
}
.style46 { font-size: 16px;
font-family: Tahoma, "MS Sans Serif", "Cordia New";
color: <?php echo $row_rs_color_title['cl_code']; ?>;
}
.style47 { font-size: 16px;
font-family: Tahoma, "MS Sans Serif", "Cordia New";
color: <?php echo $row_rs_color_note['cl_code']; ?>;
}
.style49 { font-size: 12px;
font-family: Tahoma, "MS Sans Serif", "Cordia New";
color: <?php echo $row_rs_color_note['cl_code']; ?>;
}
.style50 { font-size: 9px;
font-family: Tahoma, "MS Sans Serif", "Cordia New";
color: <?php echo $row_rs_color_note['cl_code']; ?>;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body>
<table width="955" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><? include 'include/header.php'; ?></td>
</tr>
<tr>
<td><? include 'include/menu_top.php'; ?></td>
</tr>
<tr>
<td><script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//-->
</script></td>
</tr>
<tr>
<td><table width="955" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200" valign="top"><table width="200" border="0" cellspacing="0" cellpadding="1">
<tr>
<td align="left" valign="top"><table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><? include 'include/session_login.php';?></td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top"><table width="200" border="0" cellspacing="0" cellpadding="0">
<?php if ($row_rs_m_s_p1['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu1 = $row_rs_m_s_p1['web_conf_desc']; ?>
<td align="left" valign="top"><?php include $txt_menu1 ?></td>
</tr>
<?php } //end if ?>
</table></td>
</tr>
<?php if ($row_rs_m_s_p2['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu2 = $row_rs_m_s_p2['web_conf_desc']; ?>
<td align="left" valign="top"><?php include $txt_menu2 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p3['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu3 = $row_rs_m_s_p3['web_conf_desc']; ?>
<td align="left" valign="top"><?php include $txt_menu3 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p4['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu4 = $row_rs_m_s_p4['web_conf_desc']; ?>
<td align="left" valign="top"><?php include $txt_menu4 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p5['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu5 = $row_rs_m_s_p5['web_conf_desc']; ?>
<td align="left" valign="top"><?php include $txt_menu5 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p6['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu6 = $row_rs_m_s_p6['web_conf_desc']; ?>
<td align="left" valign="top"><?php include $txt_menu6 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p16['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu16 = $row_rs_m_s_p16['web_conf_desc']; ?>
<td align="left" valign="top"><?php include $txt_menu16 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p8['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu8 = $row_rs_m_s_p8['web_conf_desc']; ?>
<td align="left" valign="top"><?php include $txt_menu8 ?></td>
</tr>
<?php } //end if ?>
</table></td>
<td width="555" valign="top"><br />
<table width="535" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="535" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="48" background="<?php echo $row_rs_bgtitle['web_conf_desc']; ?>"><div align="center" class="style46">รายการผลิตภัณฑ์ที่สั่งซื้อ</div></td>
</tr>
<tr>
<td>
<script type="text/javascript">
function chkdata(boarddata){
txtError = "กรุณากรอกข้อมูลเหล่านี้ให้ครบ ";
showError = 0;
var rex = /(\s)/;
if (boarddata.txtitem.value <= 0) {
showError = "1"
txtError = txtError + " \n จำนวนเป็น 0 หรือจำนวนติดลบ"
}
else{
if(boarddata.txtitem.value > boarddata.txtitem2.value ) {
showError = 1;
txtError = txtError + " จำนวนสินค้าที่สั่งซื้อเกินกว่าจำนวนสินค้าเหลือ";
}}
if (showError == 1) {
alert (txtError);
return false;
}
}
</script>
<form id="form1" name="form1" method="post" action="cart_detail_mng.php" onSubmit="return(chkdata(this));">
<table width="535" border="1" align="center" cellpadding="6" cellspacing="0" bordercolor="#FFFF99">
<tr>
<td width="20" background="<?php echo $row_rs_bgppt1['web_conf_desc']; ?>"><div align="center" class="style3">ลบ</div></td>
<td width="180" background="<?php echo $row_rs_bgppt1['web_conf_desc']; ?>"><div align="center" class="style3">รายการผลิตภัณฑ์<font color="#FFFFFF">
<input name="hdcart_id" type="hidden" id="hdcart_id" value="<?php echo $_SESSION['cartID']; ?>" />
</font></font></div></td>
<td width="102" background="<?php echo $row_rs_bgppt1['web_conf_desc']; ?>"><div align="center" class="style3">
จำนวน
</div></td>
<td width="81" background="<?php echo $row_rs_bgppt1['web_conf_desc']; ?>"><div align="center" class="style3">ราคา/หน่วย</div></td>
<td width="95" background="<?php echo $row_rs_bgppt1['web_conf_desc']; ?>"><div align="center" class="style3">ราคารวม</div></td>
</tr>
<?php if ($row_rs_cart_detail > 0) { // Show if recordset not empty ?>
<?php do { ?>
<tr>
<td background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>"><div align="center">
<label></label>
<label>
<input name="cbdel[]" type="checkbox" id="cbdel[]" value="<?php echo $row_rs_cart_detail['cart_detail_id']; ?>" />
</label>
</div></td>
<td background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>"><div align="center">
<label></label>
<span class="style16 style28 style20">
<input name="hdcart_detail_id[]" type="hidden" id="hdcart_detail_id[]" value="<?php echo $row_rs_cart_detail['cart_detail_id']; ?>" />
<input name="hdproduct_id[]" type="hidden" id="hdproduct_id[]" value="<?php echo $row_rs_cart_detail['pd_id']; ?>" />
</span><span class="style3"><?php echo $row_rs_cart_detail['pd_name']; ?></span></div></td>
<td background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>"><div align="center">
<input name="txtitem[]" type="text" class="style3" id="txtitem[]" value="<?php echo $row_rs_cart_detail['item']; ?>" size="15" />
<br />
<label></label>
<span class="style50">จำนวนที่เหลือขณะนี้<?php echo $row_rs_cart_detail['pd_amount']; ?></span>
<input name="txtitem2" type="hidden" id="txtitem2" value="<?php echo $row_rs_cart_detail['pd_amount']; ?>" />
</span> </div></td>
<td background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>"><div align="center" class="style3"><?php echo number_format($row_rs_cart_detail['pd_price'], 0, "", ","); ?></div>
<input name="hd_price[]" type="hidden" id="hd_price[]" value="<?php echo $row_rs_cart_detail['pd_price']; ?>" /></td>
<td background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>"><span class="style16 style24 style20">
<div align="right"><span class="style3">
<?php
$sumitem = $row_rs_cart_detail['pd_price'] * $row_rs_cart_detail['item'];
$sumtotal = $sumtotal + $sumitem;
echo number_format($sumitem, 0, "", ",");
$showcart = $row_rs_cart_detail['item'];
?>
บาท </span></div>
</td>
</tr>
<?php } while ($row_rs_cart_detail = mysql_fetch_assoc($rs_cart_detail)); ?>
<tr>
<td colspan="4" background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>" class="style3"><div align="right">ราคาผลิตภัณฑ์ไม่รวมภาษีมูลค่าเพิ่ม</div></td>
<td background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>" class="style3"><div align="right"><font color="<?php echo $row_rs_color_note['cl_code']; ?>"><?php echo number_format($sumtotal, 0, "", ",") ?> <span class="style3">บาท</span></font></div></td>
</tr>
<tr>
<td colspan="4" background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>" class="style3"><div align="right">
<input name="hd_vat" type="hidden" id="hd_vat" value="<?php echo $row_rs_vat['vat_detail']; ?>" />
ราคาภาษีมูลค่าเพิ่ม <?php echo $row_rs_vat['vat_detail']; ?> %</div></td>
<td background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>" class="style3"><div align="right"><font color="<?php echo $row_rs_color_note['cl_code']; ?>">
<?php $vat = ($sumtotal * $row_rs_vat['vat_detail'])/100 ;
$totalvat = $sumtotal + $vat;
echo number_format($vat,0,"",",") ;
?></font> บาท</div></td>
</tr>
<tr>
<td colspan="4" background="<?php echo $row_rs_bgppt1['web_conf_desc']; ?>" class="style3"><div align="right">ราคาผลิตภัณฑ์รวมทั้งสิ้น</div></td>
<td background="<?php echo $row_rs_bgppt1['web_conf_desc']; ?>" class="style3"><div align="right"><font color="<?php echo $row_rs_color_note['cl_code']; ?>">
<?php echo number_format($totalvat, 0, "", ",") ?></font> บาท</div></td>
</tr>
<tr>
<td colspan="5" background="<?php echo $row_rs_bgdown['web_conf_desc']; ?>"><div align="center">
<label>
<input type="submit" name="cmddel" id="cmddel" value="ลบรายการที่เลือก" />
</label>
<input type="submit" name="cmdrecal" id="cmdrecal" value="คำนวณราคาใหม่" />
<input type="submit" name="cmdconfirm" id="cmdconfirm" value="ยืนยันคำสั่งซื้อ" />
<input name="cmdproduct" type="submit" id="cmdproduct" onclick="MM_goToURL('parent','member_product.php');return document.MM_returnValue" value="กลับไปเลือกสินค้า" />
<br />
<span class="style49"> ***
หมายเหตุ ก่อนทำการยืนยัน กรุณาตรวจสอบการสั่งซื้อผลิตัณฑ์ของท่านให้เรียบร้อย***</span></div>
<div align="center"></div> <div align="center"></div> <div align="center"></div> <div align="center" class="style3"></div></td>
</tr>
<?php } // Show if recordset empty ?>
<?php if ($totalRows_rs_cart_detail == 0) { // Show if recordset empty ?>
<tr>
<td colspan="5" background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>"><div align="center"><span class="style47"> ไม่มีรายการสินค้าที่สั่งซื้อ </span><br />
<br />
<input name="cmdproduct2" type="submit" id="cmdproduct2" onclick="MM_goToURL('parent','member_product');return document.MM_returnValue" value="กลับไปเลือกสินค้า" />
<br />
</div></td>
</tr>
<tr>
<td colspan="5" background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>"> </td>
</tr>
<?php } // Show if recordset empty ?>
</table>
</form> </td>
</tr>
</table></td>
</tr>
</table>
<br /></td>
<td width="200" valign="top"><table width="200" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td align="right"> </td>
</tr>
<?php if ($row_rs_m_s_p15['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu15 = $row_rs_m_s_p15['web_conf_desc']; ?>
<td align="right"><?php include $txt_menu15 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p9['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu9 = $row_rs_m_s_p9['web_conf_desc']; ?>
<td align="right"><?php include $txt_menu9 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p10['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu10 = $row_rs_m_s_p10['web_conf_desc']; ?>
<td align="right"><?php include $txt_menu10 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p11['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu11 = $row_rs_m_s_p11['web_conf_desc']; ?>
<td align="right"><?php include $txt_menu11 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p12['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu12 = $row_rs_m_s_p12['web_conf_desc']; ?>
<td align="right"><?php include $txt_menu12 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p13['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu13 = $row_rs_m_s_p13['web_conf_desc']; ?>
<td align="right"><?php include $txt_menu13 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p14['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu14 = $row_rs_m_s_p14['web_conf_desc']; ?>
<td align="right"><?php include $txt_menu14 ?></td>
</tr>
<?php } //end if ?>
<?php if ($row_rs_m_s_p7['web_func_id'] == 1) { ?>
<tr>
<?php $txt_menu7 = $row_rs_m_s_p7['web_conf_desc']; ?>
<td align="right"><?php include $txt_menu7 ?></td>
</tr>
<?php } //end if ?>
</table></td>
</table></td>
</tr>
<tr>
<td><? include 'include/footer.php'; ?></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($rs_m_s_p1);
mysql_free_result($rs_m_s_p2);
mysql_free_result($rs_m_s_p3);
mysql_free_result($rs_m_s_p4);
mysql_free_result($rs_m_s_p5);
mysql_free_result($rs_m_s_p6);
mysql_free_result($rs_m_s_p7);
mysql_free_result($rs_m_s_p8);
mysql_free_result($rs_m_s_p9);
mysql_free_result($rs_m_s_p10);
mysql_free_result($rs_m_s_p11);
mysql_free_result($rs_m_s_p12);
mysql_free_result($rs_m_s_p13);
mysql_free_result($rs_m_s_p14);
mysql_free_result($rs_title);
mysql_free_result($rs_background);
mysql_free_result($rs_bgtitle);
mysql_free_result($rs_bgdetail);
mysql_free_result($rs_bgdown);
mysql_free_result($rs_cart);
mysql_free_result($rs_cart_detail);
mysql_free_result($rs_chkcart);
mysql_free_result($rs_member1);
mysql_free_result($rs_m_s_p15);
mysql_free_result($rs_m_s_p16);
mysql_free_result($rs_vat);
mysql_free_result($rs_bgppt1);
?>
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax, jQuery
|
|
|
|
|
|
Date :
2012-03-27 05:22:26 |
By :
potkung11 |
View :
1183 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จะให้ดูอะไรครับ ?
|
|
|
|
|
Date :
2012-03-27 06:28:29 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จะให้ดูการดักtextboxอะครับในส่วนของtextboxที่เป็นการวนลูกครับ
Code (PHP)
<script type="text/javascript">
function chkdata(boarddata){
txtError = "กรุณากรอกข้อมูลเหล่านี้ให้ครบ ";
showError = 0;
var rex = /(\s)/;
if (boarddata.txtitem.value <= 0) {
showError = "1"
txtError = txtError + " \n จำนวนเป็น 0 หรือจำนวนติดลบ"
}
else{
if(boarddata.txtitem.value > boarddata.txtitem2.value ) {
showError = 1;
txtError = txtError + " จำนวนสินค้าที่สั่งซื้อเกินกว่าจำนวนสินค้าเหลือ";
}}
if (showError == 1) {
alert (txtError);
return false;
}
}
</script>
<form id="form1" name="form1" method="post" action="cart_detail_mng.php" onSubmit="return(chkdata(this));">
textboxจะมีแค่ตัวเดียวครับคือ
Code (PHP)
<?php do { ?>
<tr>
<td background="<?php echo $row_rs_bgdetail['web_conf_desc']; ?>">
<div align="center">
<input name="txtitem[]" type="text" id="txtitem[]" value="<?php echo $row_rs_cart_detail['item']; ?>" size="15" />
<span class="style50">จำนวนที่เหลือขณะนี้<?php echo $row_rs_cart_detail['pd_amount']; ?></span>
<input name="txtitem2" type="hidden" id="txtitem2" value="<?php echo $row_rs_cart_detail['pd_amount']; ?>" />
</div></td>
</tr>
<?php } while ($row_rs_cart_detail = mysql_fetch_assoc($rs_cart_detail)); ?>
|
ประวัติการแก้ไข 2012-03-27 22:09:21 2012-03-27 22:10:54
|
|
|
|
Date :
2012-03-27 22:06:17 |
By :
potkung11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|