|  | 
	                
  
    | 
	 
        ช่วยทีค่ะ อยากทำการเช็คจำนวนสินค้ากับ stock ที่มี ถ้าใส่เกิน ให้เด้งเตือนว่า สินค้าไม่พอค่ะ     |  
    |  |  
 
              
  
    | 
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ช่วยดูให้หน่อยค่ะ มันไม่ทำงานตรงส่วนjavascript ค่ะ Code (PHP)
 
 if(trim($_POST["action"]) == "Update")
{
for($i=0;$i<count($_POST["txtQua"]);$i++)
{	
	$strP=$_POST[txtP][$i];
	$strQ=$_POST["txtQua"][$i];
	if($strQ <= 0)
	{
	$strQ=1;
	}
	$_SESSION["strQuanlity"][$strP]=$strQ;
	$result=select("product","where 1=1 and ProductID='".$_SESSION["strProductID"][$strP]."'");
	if($result["Stock"] < $strQ)
	{
	$_SESSION["strQuanlity"][$strP]=$result["Stock"];
									echo"<script language='JavaScript'>";
									echo"alert('รหัสสินค้า [ $result[ProductCode] ] มีจำนวน Stock ไม่เพียงพอ');";
									echo"</script>";	
	}
	
}	
	session_write_close();
	//============ กระโดด Refresh ใหม่อีกรอบ
	header("location:$_SERVER[PHP_SELF]");
}	
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 11:33:57 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 $result=select("product","where 1=1 and ProductID='".$_SESSION["strProductID"][$strP]."'"); // function นี้ มี mysql_fetch_array หรือยังครับ ??
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 11:44:46 | By :
                            Ex-[S]i[L]e[N]t |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ไม่มีค่ะ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 11:50:05 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
   <?
  if(trim($_POST["action"]) == "Update")
{
for($i=0;$i<count($_POST["txtQua"]);$i++)
{	
	$strP=$_POST[txtP][$i];
	$strQ=$_POST["txtQua"][$i];
	if($strQ <= 0)
	{
	$strQ=1;
	}
	$_SESSION["strQuanlity"][$strP]=$strQ;
	$select=select("product","where 1=1 and ProductID='".$_SESSION["strProductID"][$strP]."'");
	$result=mysql_fetch_array($select);
	if($result["Stock"] < $strQ)
	{
	$_SESSION["strQuanlity"][$strP]=$result["Stock"];
									echo"<script language='JavaScript'>";
									echo"alert('รหัสสินค้า [ $result[ProductCode] ] มีจำนวน Stock ไม่เพียงพอ');";
									echo"</script>";	
	}
	
}	
	session_write_close();
	//============ กระโดด Refresh ใหม่อีกรอบ
	header("location:$_SERVER[PHP_SELF]");
}	
  ?>
ลองแบบนี้ครับ เพิ่ม mysql_fetch_array ในการที่จะใช้ array ของแต่ละส่วนนั้นจำเป็นต้องใช้คำสั่งเบื้องต้นนี้ครับ
  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 11:54:17 | By :
                            Ex-[S]i[L]e[N]t |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ไม่ได้อ่ะค่ะ ถ้าเพิ่ม mysql_fetch_array ไปแล้ว หน้าแสดงผล ตรงจำนวนสินค้ามันเป็นช่องว่างไปเลยอ่ะค่ะ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 11:58:38 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | code เต็มๆมันเป็นหน้า cart ค่ะ Code (PHP)
 
 <?
ob_start();
//============ Start Session และทำการเรียก Function ติดต่อฐานข้อมูล 
session_start();
require("connect/connect.php");
require("connect/function.php");
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>www.Zebra Ball.com</title>
<link href="css/styles.css" rel="stylesheet" type="text/css">
</head>
<body topmargin="0">
<table width="778" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
  <tr> 
    <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td>
            <?php require_once('head.php'); ?>
<?
//============ Check ว่ามีซ้ำแล้วหรือยัง
if($_GET["ProductID"] != "")
{
	for($i=0;$i<=count($_SESSION["strProductID"]);$i++)
	{
			if($_SESSION["strProductID"][$i] == $_GET["ProductID"])
			{
			header("location:$_SERVER[PHP_SELF]");
			exit();
			}
	}
}
//============ ถ้ามีการเลือกรายการสินค้าให้เก็บลง Session
if(trim($_GET["ProductID"]) != "")
{
	$_SESSION["strP"]=$_SESSION["strP"]+1;
	$_SESSION["strProductID"][$_SESSION[strP]]=$_GET["ProductID"];
	$_SESSION["strQuanlity"][$_SESSION[strP]]=1;
	session_write_close();
	header("location:$_SERVER[PHP_SELF]");
}	
//============ กรณีลบรายการสั่งซื้อ
if(trim($_GET["action"]) == "Del")
{
	$_SESSION["strProductID"][$_GET[P]]="";
	$_SESSION["strQuanlity"][$_GET[P]]="";
	session_write_close();
	header("location:$_SERVER[PHP_SELF]");
}	
//============ กรณีการแก้ไขรายการสั่งซื้อ
if(trim($_POST["action"]) == "Update")
{
for($i=0;$i<count($_POST["txtQua"]);$i++)
{	
	$strP=$_POST[txtP][$i];
	$strQ=$_POST["txtQua"][$i];
	if($strQ <= 0)
	{
	$strQ=1;
	}
	$_SESSION["strQuanlity"][$strP]=$strQ;
	$result=select("product","where 1=1 and ProductID='".$_SESSION["strProductID"][$strP]."'");
	if($result["Stock"] < $strQ)
	{
	//$_SESSION["strQuanlity"][$strP]=$result["Stock"];
									echo"<script language='JavaScript'>";
									echo"alert('รหัสสินค้า [ $result[ProductCode] ] มีจำนวน Stock ไม่เพียงพอ');";
									echo"</script>";	
									echo $result["Stock"];
									echo $strQ;
	}
}	
	session_write_close();
	//============ กระโดด Refresh ใหม่อีกรอบ
	header("location:$_SERVER[PHP_SELF]");
}	
?>			
          </td>
        </tr>
        <tr> 
          <td><table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#f2f2f6" bgcolor="#FFFFFF">
              <tr> 
                <td width="23%" valign="top"> <?php require_once('menuleft.php'); ?> <br> </td>
                <td width="54%" valign="top"> 
                  <table border="0" cellpadding="0" cellspacing="0" style="width: 434px; height: 638px">
                    <!--DWLayoutTable-->
                    <tr>
                      <td valign="top">
                        <form action="" method="post" name="frmCart" id="frmCart">
                          <input name="Button10" type="hidden" value="Add" id="Action" />
                          <table width="415" border="0">
                            <tr> 
                              <td><table width="418" height="22" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
                                  <tr> 
                                    <td width="8"> <img src="image/img4.jpg" width="8" height="22" alt=""></td>
                                    <td width="389" background="image/img5.jpg"><div align="center"><strong>รายการสั่งซื้อ 
                                        <input name="action" type="hidden" id="action" value="Update">
                                        </strong></div></td>
                                    <td width="9"> <img src="image/img6.jpg" width="9" height="22" alt=""></td>
                                  </tr>
                                </table>
                                <strong> </strong></td>
                            </tr>
                            <tr> 
                              <td> </td>
                            </tr>
                            <tr> 
                              <td><table width="98%" height="21" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
                                  <tr bgcolor="#FFFFFF"> 
                                    <td><div align="center">ลำดับ</div></td>
                                    <td>ชื่อสินค้า</td>
                                    <td><div align="center">ราคา</div></td>
                                    <td>ค่าจัดส่ง</td>
                                    <td><div align="center">จำนวน</div></td>
                                    <td><div align="center">รวม</div></td>
                                  </tr>
                                  <?
//============ ทำการแสงรายการที่ได้เลือกว่ามีกี่รายการ
$strNum=0;
$strTotal=0;
for($i=0;$i<=count($_SESSION["strProductID"]);$i++)
{
//============ เลือกว่ารายการสินค้าใดบ้าง
$result=select("product","where 1=1 and ProductID='".$_SESSION["strProductID"]["$i"]."' ");
if($result)
{
$strNum++;
?>
                                  <tr bgcolor="#FFFFFF"> 
                                    <td width="9%"> <div align="center"> 
                                        <?=$strNum;?>
                                        <a href="javascript:if(confirm('ลบรายการสินค้า')==true){window.location='<?=$_SERVER['PHP_SELF'];?>?action=Del&P=<?=$i;?>';}"><img src="image/deleteC.gif" width="12" height="11" border="0"></a></div></td>
                                    <td width="48%"> 
                                      <?=$result["ProductName"];?>
                                    </td>
                                    <td width="14%"> <div align="right"> 
                                        <?="".number_format($result["PriceNormal"], 2,'.',',');?>
                                      </div></td>
                                    <td width="13%"> 
                                      <div align="right">
                                        <?="".number_format($result["PriceSend"], 2,'.',',');?>
                                      </div></td>
                                    <td width="13%"><div align="center"> 
                                        <input name="txtP[]" type="hidden" id="txtP[]" value="<?=$i;?>">
                                        <input name="txtQua[]" type="text" id="txtQua<?=$strNum;?>" style="width:30px;text-align:right" value="<?=$_SESSION["strQuanlity"]["$i"];?>" maxlength="3" onChange="checknum(this.value,'txtQua<?=$strNum;?>');">
                                      </div></td>
                                    <td width="16%"> <div align="right"> 
                                        <?="".number_format(($result["PriceNormal"]+$result["PriceSend"])*$_SESSION["strQuanlity"]["$i"], 2,'.',',');?>
                                      </div></td>
                                  </tr>
                                  <?
								  $strTotal=$strTotal+(($result["PriceNormal"]+$result["PriceSend"])*$_SESSION["strQuanlity"]["$i"]);
}
}
?>
                                </table>
                                <br> <table width="98%" height="21" border="0" align="center" cellpadding="2" cellspacing="1">
                                  <tr bgcolor="#FFFFFF"> 
                                    <td><div align="right">จำนวน (รายการ)</div></td>
                                    <td> <div align="right"> 
                                        <?=$strNum;?>
                                      </div></td>
                                  </tr>
                                  <tr bgcolor="#FFFFFF"> 
                                    <td> <div align="right">ราคารวม (บาท)</div></td>
                                    <td width="16%"> <div align="right"> 
                                        <?="".number_format($strTotal, 2,'.',',');?>
                                      </div></td>
                                  </tr>
                                                                 </table></td>
                            </tr>
	<tr>
                              <td style="width: 424px"><div align="center"><br>
                                  <?
							if($strNum==0)
							{
							echo "<br><center><strong><font color=red>ไม่มีรายการสั่งซื้อ</font></strong></center><br><br>";
							}
							?>
                                  <input name="BtnContinute" type="button" class="button" id="BtnContinute2" value="ซื้อสินค้าต่อ" onClick="window.location='index.php';">
                                    
                                  <?
								  if($strNum>0)
								  {?>
                                  <input name="BtnCalu" type="submit" class="button" id="BtnCalu" value="คำนวณเงินใหม่">
                                    
                                  <input name="BtnPayment" type="button" class="button" id="BtnPayment" value="ชำระเงิน" onClick="window.location='pay.php';">
                                  <?}?>
                                  <br>
                                </div></td>
                            <td style="height: 42px; width: 10px"> </td>
	</tr>
                          </table>
                          <p class="style59"> </p>
                        </form>
                        <p class="style59"> 
						<script language="JavaScript">
						function checknum(value,fields)
						{
						if(!check_number(value))
						{
						eval("document.all."+fields+".value='1';");
						alert('กรอกจำนวนไม่ถูกต้อง');
						}
						}
						
						function check_number(ch){
							var len, digit;
							if(ch == " "){ 
								return false;
									 len=0;
								}else{
									 len = ch.length;
							}
							for(var i=0 ; i<len ; i++)
							{
								digit = ch.charat(i)
								if(digit >="0" && digit <="9"){
									;	
								}else{
									return false;					
								}		
							}		
							return true;
						}						
						</script></p>
                        <p class="style59"> </p>
                        <p class="style59"> </p></td>
                    </tr>
                  </table></td>
                <td width="23%" valign="top"> <?php require_once('menuright.php'); ?> </td>
              </tr>
              <tr> 
                <td colspan="3" valign="top">
                  <?php require_once('down.php'); ?>
                </td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 12:01:08 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 if(trim($_POST["action"]) == "Update"){
     $txtP=$_POST['txtP'];
	 $txtQua=$_POST['txtQua'];
	 for($i=0;<=count($txtQua);$i++{
	      if($txtQua[$i] <= 0){
		     $txtQua[$i]=1;
		  }
		  $_SESSION['strQuanlity'][$txtP[$i]]=$txtQua[$i];
		  $check=select("product","WHERE ProductID='".$_SESSION['ProductID'][$txtP[$i]]."'");
		  if($check['Stock']<$_SESSION['strQuanlity'][$i]){
		      echo "<script>alert(\"สินค้าไม่เพียงพอ \");</script>";
		  }
	 } 
}
ลองดูครับ
 
 |  
              | 
 ประวัติการแก้ไข
 2013-02-25 12:27:12
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 12:24:10 | By :
                            Ex-[S]i[L]e[N]t |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ไม่ได้อ่ะค่ะ ไม่รู้ทำถูกไหม เอาไปวางต่อบรรทัดที่80อ่ะค่ะ แต่มันก็ไม่ขึ้นการแจ้งเตือน สินค้าไม่เพียงพอเลย Code (PHP)
 
 if(trim($_POST["action"]) == "Update")
{
for($i=0;$i<count($_POST["txtQua"]);$i++)
{	
	$strP=$_POST[txtP][$i];
	$strQ=$_POST["txtQua"][$i];
	if($strQ <= 0)
	{
	$strQ=1;
	}
	$_SESSION["strQuanlity"][$strP]=$strQ;
	$result=select("product","where 1=1 and ProductID='".$_SESSION["strProductID"][$strP]."'");
	if($result["Stock"] < $strQ)
	{
	//$_SESSION["strQuanlity"][$strP]=$result["Stock"];
									echo"<script language='JavaScript'>";
									echo"alert('รหัสสินค้า [ $result[ProductCode] ] มีจำนวน Stock ไม่เพียงพอ');";
									echo"</script>";	
									echo $result["Stock"];
									echo $strQ;
	}
}	
if(trim($_POST["action"]) == "Update"){     
$txtP=$_POST['txtP'];    
$txtQua=$_POST['txtQua'];  
for($i=0;$i<count(txtQua);$i++)
if($txtQua[$i] <= 0){  
$txtQua[$i]=1; 
} 
$_SESSION['strQuanlity'][$txtP[$i]]=$txtQua[$i]; 
$check=select("product","WHERE ProductID='".$_SESSION['ProductID'][$txtP[$i]]."'"); 
if($check['Stock']<$_SESSION['strQuanlity'][$i]){       
echo "<script>alert(\"สินค้าไม่เพียงพอ \");</script>";     
} 
}  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 12:48:35 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลบ action เดิมก่อนสิครับ แล้วเอาไปแทนที่  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 12:55:01 | By :
                            Ex-[S]i[L]e[N]t |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ถ้าลบ action เดิมออก เวลาแก้ไขจำนวน ตัวเลข แล้วกดคำนวนใหม่มันจะกลับไปที่ค่าเดิม ไม่ใช่ค่าที่แก้ไขอ่ะค่ะ แล้วก็ มันยังไม่เด้งส่วนของ echo "<script>alert(\"สินค้าไม่เพียงพอ \");</script>";   เลยอ่ะค่ะ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 13:16:54 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ขอดู cod ล่าสุด 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 14:54:21 | By :
                            Ex-[S]i[L]e[N]t |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | นี่ค่ะ Code (PHP)
 
 <?
ob_start();
//============ Start Session และทำการเรียก Function ติดต่อฐานข้อมูล 
session_start();
require("connect/connect.php");
require("connect/function.php");
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>www.Zebra Ball.com</title>
<link href="css/styles.css" rel="stylesheet" type="text/css">
</head>
<body topmargin="0">
<table width="778" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
  <tr> 
    <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td>
            <?php require_once('head.php'); ?>
<?
//============ Check ว่ามีซ้ำแล้วหรือยัง
if($_GET["ProductID"] != "")
{
	for($i=0;$i<=count($_SESSION["strProductID"]);$i++)
	{
			if($_SESSION["strProductID"][$i] == $_GET["ProductID"])
			{
			header("location:$_SERVER[PHP_SELF]");
			exit();
			}
	}
}
//============ ถ้ามีการเลือกรายการสินค้าให้เก็บลง Session
if(trim($_GET["ProductID"]) != "")
{
	$_SESSION["strP"]=$_SESSION["strP"]+1;
	$_SESSION["strProductID"][$_SESSION[strP]]=$_GET["ProductID"];
	$_SESSION["strQuanlity"][$_SESSION[strP]]=1;
	session_write_close();
	header("location:$_SERVER[PHP_SELF]");
}	
//============ กรณีลบรายการสั่งซื้อ
if(trim($_GET["action"]) == "Del")
{
	$_SESSION["strProductID"][$_GET[P]]="";
	$_SESSION["strQuanlity"][$_GET[P]]="";
	session_write_close();
	header("location:$_SERVER[PHP_SELF]");
}	
//============ กรณีการแก้ไขรายการสั่งซื้อ
if(trim($_POST["action"]) == "Update"){     
$txtP=$_POST['txtP'];    
$txtQua=$_POST['txtQua'];  
for($i=0;$i<count(txtQua);$i++)
if($txtQua[$i] <= 0){  
$txtQua[$i]=1; 
} 
$_SESSION['strQuanlity'][$txtP[$i]]=$txtQua[$i]; 
$check=select("product","WHERE ProductID='".$_SESSION['ProductID'][$txtP[$i]]."'"); 
if($check['Stock']<$_SESSION['strQuanlity'][$i]){       
echo "<script>alert(\"สินค้าไม่เพียงพอ \");</script>";     
} 
	session_write_close();
	//============ กระโดด Refresh ใหม่อีกรอบ
	header("location:$_SERVER[PHP_SELF]");
}	
?>			
          </td>
        </tr>
        <tr> 
          <td><table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#f2f2f6" bgcolor="#FFFFFF">
              <tr> 
                <td width="23%" valign="top"> <?php require_once('menuleft.php'); ?> <br> </td>
                <td width="54%" valign="top"> 
                  <table border="0" cellpadding="0" cellspacing="0" style="width: 434px; height: 638px">
                    <!--DWLayoutTable-->
                    <tr>
                      <td valign="top">
                        <form action="" method="post" name="frmCart" id="frmCart">
                          <input name="Button10" type="hidden" value="Add" id="Action" />
                          <table width="415" border="0">
                            <tr> 
                              <td><table width="418" height="22" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
                                  <tr> 
                                    <td width="8"> <img src="image/img4.jpg" width="8" height="22" alt=""></td>
                                    <td width="389" background="image/img5.jpg"><div align="center"><strong>รายการสั่งซื้อ 
                                        <input name="action" type="hidden" id="action" value="Update">
                                        </strong></div></td>
                                    <td width="9"> <img src="image/img6.jpg" width="9" height="22" alt=""></td>
                                  </tr>
                                </table>
                                <strong> </strong></td>
                            </tr>
                            <tr> 
                              <td> </td>
                            </tr>
                            <tr> 
                              <td><table width="98%" height="21" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
                                  <tr bgcolor="#FFFFFF"> 
                                    <td><div align="center">ลำดับ</div></td>
                                    <td>ชื่อสินค้า</td>
                                    <td><div align="center">ราคา</div></td>
                                    <td>ค่าจัดส่ง</td>
                                    <td><div align="center">จำนวน</div></td>
                                    <td><div align="center">รวม</div></td>
                                  </tr>
                                  <?
//============ ทำการแสงรายการที่ได้เลือกว่ามีกี่รายการ
$strNum=0;
$strTotal=0;
for($i=0;$i<=count($_SESSION["strProductID"]);$i++)
{
//============ เลือกว่ารายการสินค้าใดบ้าง
$result=select("product","where 1=1 and ProductID='".$_SESSION["strProductID"]["$i"]."' ");
if($result)
{
$strNum++;
?>
                                  <tr bgcolor="#FFFFFF"> 
                                    <td width="9%"> <div align="center"> 
                                        <?=$strNum;?>
                                        <a href="javascript:if(confirm('ลบรายการสินค้า')==true){window.location='<?=$_SERVER['PHP_SELF'];?>?action=Del&P=<?=$i;?>';}"><img src="image/deleteC.gif" width="12" height="11" border="0"></a></div></td>
                                    <td width="48%"> 
                                      <?=$result["ProductName"];?>
                                    </td>
                                    <td width="14%"> <div align="right"> 
                                        <?="".number_format($result["PriceNormal"], 2,'.',',');?>
                                      </div></td>
                                    <td width="13%"> 
                                      <div align="right">
                                        <?="".number_format($result["PriceSend"], 2,'.',',');?>
                                      </div></td>
                                    <td width="13%"><div align="center"> 
                                        <input name="txtP[]" type="hidden" id="txtP[]" value="<?=$i;?>">
                                        <input name="txtQua[]" type="text" id="txtQua<?=$strNum;?>" style="width:30px;text-align:right" value="<?=$_SESSION["strQuanlity"]["$i"];?>" maxlength="3" onChange="checknum(this.value,'txtQua<?=$strNum;?>');">
                                      </div></td>
                                    <td width="16%"> <div align="right"> 
                                        <?="".number_format(($result["PriceNormal"]+$result["PriceSend"])*$_SESSION["strQuanlity"]["$i"], 2,'.',',');?>
                                      </div></td>
                                  </tr>
                                  <?
								  $strTotal=$strTotal+(($result["PriceNormal"]+$result["PriceSend"])*$_SESSION["strQuanlity"]["$i"]);
}
}
?>
                                </table>
                                <br> <table width="98%" height="21" border="0" align="center" cellpadding="2" cellspacing="1">
                                  <tr bgcolor="#FFFFFF"> 
                                    <td><div align="right">จำนวน (รายการ)</div></td>
                                    <td> <div align="right"> 
                                        <?=$strNum;?>
                                      </div></td>
                                  </tr>
                                  <tr bgcolor="#FFFFFF"> 
                                    <td> <div align="right">ราคารวม (บาท)</div></td>
                                    <td width="16%"> <div align="right"> 
                                        <?="".number_format($strTotal, 2,'.',',');?>
                                      </div></td>
                                  </tr>
                                                                 </table></td>
                            </tr>
	<tr>
                              <td style="width: 424px"><div align="center"><br>
                                  <?
							if($strNum==0)
							{
							echo "<br><center><strong><font color=red>ไม่มีรายการสั่งซื้อ</font></strong></center><br><br>";
							}
							?>
                                  <input name="BtnContinute" type="button" class="button" id="BtnContinute2" value="ซื้อสินค้าต่อ" onClick="window.location='index.php';">
                                    
                                  <?
								  if($strNum>0)
								  {?>
                                  <input name="BtnCalu" type="submit" class="button" id="BtnCalu" value="คำนวณเงินใหม่">
                                    
                                  <input name="BtnPayment" type="button" class="button" id="BtnPayment" value="ชำระเงิน" onClick="window.location='pay.php';">
                                  <?}?>
                                  <br>
                                </div></td>
                            <td style="height: 42px; width: 10px"> </td>
	</tr>
                          </table>
                          <p class="style59"> </p>
                        </form>
                        <p class="style59"> 
						<script language="JavaScript">
						function checknum(value,fields)
						{
						if(!check_number(value))
						{
						eval("document.all."+fields+".value='1';");
						alert('กรอกจำนวนไม่ถูกต้อง');
						}
						}
						
						function check_number(ch){
							var len, digit;
							if(ch == " "){ 
								return false;
									 len=0;
								}else{
									 len = ch.length;
							}
							for(var i=0 ; i<len ; i++)
							{
								digit = ch.charat(i)
								if(digit >="0" && digit <="9"){
									;	
								}else{
									return false;					
								}		
							}		
							return true;
						}						
						</script></p>
                        <p class="style59"> </p>
                        <p class="style59"> </p></td>
                    </tr>
                  </table></td>
                <td width="23%" valign="top"> <?php require_once('menuright.php'); ?> </td>
              </tr>
              <tr> 
                <td colspan="3" valign="top">
                  <?php require_once('down.php'); ?>
                </td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 15:27:10 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ตรงนี้หรือเปล่าครับ บรรทัดที่ 56 
 if(trim($_POST["action"]) == "Update"){
 
 มันควรจะเป็น $_GET["action"] หรือเปล่า เพราะก่อนหน้านั้นเป็น $_GET["action"] หมดเลย
 
 |  
              | 
 ประวัติการแก้ไข
 2013-02-25 16:08:01
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 16:07:09 | By :
                            cookiephp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลองแล้วค่ะไม่ได้ค่ะ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 16:16:28 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลองเช็คดูก่อนครับ ว่ามันเข้าไปทำงานในส่วนบรรทัดที่ 57 - 66 หรือเปล่า ลองใส่ echo 'UPDATE'; ไว้เพื่อให้มองเห็นก็ได้ครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 16:25:06 | By :
                            cookiephp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | echo 'UPDATE'; ใส่ไว้ตรงไหนเหรอคะ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 16:40:09 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | เอิ่ม.. ลองแล้วค่ะ ผลคือ มันแก้ไขจำนวนสินค้าไม่ได้เลย แล้วก็ ยังไม่มีการแจ้งเตือนด้วยค่ะ ส่วนที่ echo ก็ไม่ขึ้นเลย เราเลยลองcodeเก่า 
 Code (PHP)
 
 //============ กรณีการแก้ไขรายการสั่งซื้อ
if(trim($_POST["action"]) == "Update")
{
for($i=0;$i<count($_POST["txtQua"]);$i++)
{	
	$strP=$_POST[txtP][$i];
	$strQ=$_POST["txtQua"][$i];
	if($strQ <= 0)
	{
	$strQ=1;
	}
	$_SESSION["strQuanlity"][$strP]=$strQ;
	$result=select("product","where 1=1 and ProductID='".$_SESSION["strProductID"][$strP]."'");
	if($result["Stock"] < $strQ)
	{
	//$_SESSION["strQuanlity"][$strP]=$result["Stock"];
		echo "<script>javascript:chkConfirm('".$result[ProductID]."');</script>";
		echo "<script>javascript:chkConfirm('".$_SESSION['bk'][$index]["id"]."','".$_SESSION['bk'][$index]["qty"]."');</script>;";
	}
}	
 อันนี้อ่ะค่ะลอง echo ค่าของ $strQ ดูมันไม่ขึ้นอ่ะค่ะ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 17:17:20 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | โค้ดทั้งหมดนี้เอามาจากไหนครับ เป็นโปรเจ็คตัวอย่างจากไหนครับ - - มันยุ่งเหยิงมากเลย
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 17:26:38 | By :
                            cookiephp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | เอิ่ม เอามาจาก ที่ไหนสักที่อ่ะค่ะ ที่เกี่ยวกับ ระบบขายของและมี ตะกร้าสินค้า พอดีว่าโหลดมาประมาณ เกือบๆเดือนแล้วอ่ะค่ะ แก้มาเรื่อยๆ เพิ่งเริ่มหัด ถ้าจะเอา code ไปช่วยแก้ก็ได้นะคะ >< เดี๋ยวส่งให้ทางe-mail 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 17:30:09 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ขอบอกตรงๆ ว่าโค้ดแบบนี้ เขียนใหม่เร็วกว่าแก้เยอะเลยครับ - - 
 เขียนซ้ำซ้อน และซับซ้อนเกินกว่าที่ควรจะเป็น
 
 แต่เอามาดูก็ได้ครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 17:40:37 | By :
                            cookiephp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ส่งลิ้งให้ใน pm แล้วค่ะ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 17:49:54 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | เจอที่ผิดแล้วครับ แต่ไม่สามารถอธิบายได้ว่าเพราะอะไร 
 บรรทัดที่ 94
 
 <input name="action" type="hidden" id="action" value="Update">
 
 เมื่อไหร่ก็ตามถ้า name="action" การส่งข้อมูลจะกลายเป็นแบบ GET ไปครับ ถึงแม้ว่าเราจะกำหนดใน <form> ว่า method="post" ก็ตาม
 
 ดังนั้นให้เปลี่ยนชื่อเป็นอย่างอื่น เช่น name="post_action"
 
 และไปแก้ตรงบรรทัดที่ 56
 
 if(trim($_POST["action"]) == "Update"){
 
 โดยแก้ action ให้เป็น post_action ครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 18:33:34 | By :
                            cookiephp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ผมแก้ให้แค่นี้นะครับ เพราะปัญหาที่คุณติดจริงๆ มันอยู่ตรงนี้ ส่วนการตรวจจำนวนคุณอาจจะทำถูกแล้วก็ได้ ขอให้ลองทำต่อไปครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 18:35:59 | By :
                            cookiephp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ขอบคุณค่ะจะลองแก้ไขดู เพราะตอนนี้ echo $strQ ยังไงค่าก็ไม่ขึ้นเลยค่ะ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-02-25 18:49:07 | By :
                            habuu |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |