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,028

HOME > PHP > PHP Forum > ช่วยทีค่ะ อยากทำการเช็คจำนวนสินค้ากับ stock ที่มี ถ้าใส่เกิน ให้เด้งเตือนว่า สินค้าไม่พอค่ะ



 

ช่วยทีค่ะ อยากทำการเช็คจำนวนสินค้ากับ stock ที่มี ถ้าใส่เกิน ให้เด้งเตือนว่า สินค้าไม่พอค่ะ

 



Topic : 091402



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



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




คืออยากทำการเช็คจำนวนสินค้ากับstockที่มี ถ้าใส่จำนวนสินค้าเกิน ให้เด้งเตือนว่า สินค้าไม่พอค่ะ แต่ไม่รู้จะเขียนออกมายังไงค่ะ รบกวนช่วยทีนะคะ
อันนี้เป็นcode หน้า confirm ค่ะ ถ้ากดยืนยันการสั่งซื้อมันจะบันทึกข้อมูลไปในฐานข้อมูลให้อ่ะค่ะ



Tag : PHP, MySQL, JavaScript, CakePHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-02-25 05:45:31 By : habuu View : 6892 Reply : 26
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

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

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

Go to : เช็คสต๊อด ก่อนเบิกสินค้าทำไงหรือครับ เมื่อสินค้าใน คลังสินค้าต่ำกว่า 10 ชิ้น จะไม่สามารถเบิกได้ พอมี code ให้ดูมั้ยครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 06:18:46 By : mr.win
 


 

No. 2



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



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


ช่วยดูให้หน่อยค่ะ มันไม่ทำงานตรงส่วน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
 

 

No. 3



โพสกระทู้ ( 4,169 )
บทความ ( 7 )

Hall of Fame 2012

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


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
 


 

No. 4



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



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


ไม่มีค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 11:50:05 By : habuu
 


 

No. 5



โพสกระทู้ ( 4,169 )
บทความ ( 7 )

Hall of Fame 2012

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


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
 


 

No. 6



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



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


ไม่ได้อ่ะค่ะ ถ้าเพิ่ม mysql_fetch_array ไปแล้ว หน้าแสดงผล ตรงจำนวนสินค้ามันเป็นช่องว่างไปเลยอ่ะค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 11:58:38 By : habuu
 


 

No. 7



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



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


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>&nbsp;</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';">
                                  &nbsp; 
                                  <?
								  if($strNum>0)
								  {?>
                                  <input name="BtnCalu" type="submit" class="button" id="BtnCalu" value="คำนวณเงินใหม่">
                                  &nbsp; 
                                  <input name="BtnPayment" type="button" class="button" id="BtnPayment" value="ชำระเงิน" onClick="window.location='pay.php';">
                                  <?}?>
                                  <br>
                                </div></td>
                            <td style="height: 42px; width: 10px">&nbsp;</td>
	</tr>
                          </table>
                          <p class="style59">&nbsp;</p>
                        </form>
                        <p class="style59">&nbsp;
						<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">&nbsp;</p>
                        <p class="style59">&nbsp;</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
 


 

No. 8



โพสกระทู้ ( 4,169 )
บทความ ( 7 )

Hall of Fame 2012

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


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
 


 

No. 9



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



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


ไม่ได้อ่ะค่ะ ไม่รู้ทำถูกไหม เอาไปวางต่อบรรทัดที่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
 


 

No. 10



โพสกระทู้ ( 4,169 )
บทความ ( 7 )

Hall of Fame 2012

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


ลบ action เดิมก่อนสิครับ แล้วเอาไปแทนที่
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 12:55:01 By : Ex-[S]i[L]e[N]t
 


 

No. 11



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



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


ถ้าลบ action เดิมออก เวลาแก้ไขจำนวน ตัวเลข แล้วกดคำนวนใหม่มันจะกลับไปที่ค่าเดิม ไม่ใช่ค่าที่แก้ไขอ่ะค่ะ แล้วก็ มันยังไม่เด้งส่วนของ echo "<script>alert(\"สินค้าไม่เพียงพอ \");</script>"; เลยอ่ะค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 13:16:54 By : habuu
 


 

No. 12



โพสกระทู้ ( 4,169 )
บทความ ( 7 )

Hall of Fame 2012

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


ขอดู cod ล่าสุด
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 14:54:21 By : Ex-[S]i[L]e[N]t
 


 

No. 13



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



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


นี่ค่ะ
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>&nbsp;</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';">
                                  &nbsp; 
                                  <?
								  if($strNum>0)
								  {?>
                                  <input name="BtnCalu" type="submit" class="button" id="BtnCalu" value="คำนวณเงินใหม่">
                                  &nbsp; 
                                  <input name="BtnPayment" type="button" class="button" id="BtnPayment" value="ชำระเงิน" onClick="window.location='pay.php';">
                                  <?}?>
                                  <br>
                                </div></td>
                            <td style="height: 42px; width: 10px">&nbsp;</td>
	</tr>
                          </table>
                          <p class="style59">&nbsp;</p>
                        </form>
                        <p class="style59">&nbsp;
						<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">&nbsp;</p>
                        <p class="style59">&nbsp;</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
 


 

No. 14



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

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

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

ตรงนี้หรือเปล่าครับ บรรทัดที่ 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
 


 

No. 15



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



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


ลองแล้วค่ะไม่ได้ค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 16:16:28 By : habuu
 


 

No. 16



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

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

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

ลองเช็คดูก่อนครับ ว่ามันเข้าไปทำงานในส่วนบรรทัดที่ 57 - 66 หรือเปล่า ลองใส่ echo 'UPDATE'; ไว้เพื่อให้มองเห็นก็ได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 16:25:06 By : cookiephp
 


 

No. 17



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



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


echo 'UPDATE';
ใส่ไว้ตรงไหนเหรอคะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 16:40:09 By : habuu
 


 

No. 18



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

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

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

ตรงนี้ครับ - -
แล้วก็เพิ่มสีแดงข้างล่างด้วยนะครับ
ลองรันดู แล้วก็อปปี้ผลมาให้ดูหน่อย

if(trim($_POST["action"]) == "Update"){ echo '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]]."'"); echo '<pre>'; var_dump($check); var_dump($_SESSION); echo '</pre>'; if($check['Stock']<$_SESSION['strQuanlity'][$i]){ echo "<script>alert(\"สินค้าไม่เพียงพอ \");</script>"; } session_write_close(); //============ กระโดด Refresh ใหม่อีกรอบ header("location:$_SERVER[PHP_SELF]"); }

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 16:58:16 By : cookiephp
 


 

No. 19



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



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


เอิ่ม.. ลองแล้วค่ะ ผลคือ มันแก้ไขจำนวนสินค้าไม่ได้เลย แล้วก็ ยังไม่มีการแจ้งเตือนด้วยค่ะ ส่วนที่ 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
 


 

No. 20



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

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

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

โค้ดทั้งหมดนี้เอามาจากไหนครับ เป็นโปรเจ็คตัวอย่างจากไหนครับ - -
มันยุ่งเหยิงมากเลย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 17:26:38 By : cookiephp
 


 

No. 21



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



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


เอิ่ม เอามาจาก ที่ไหนสักที่อ่ะค่ะ ที่เกี่ยวกับ ระบบขายของและมี ตะกร้าสินค้า พอดีว่าโหลดมาประมาณ เกือบๆเดือนแล้วอ่ะค่ะ แก้มาเรื่อยๆ เพิ่งเริ่มหัด ถ้าจะเอา code ไปช่วยแก้ก็ได้นะคะ >< เดี๋ยวส่งให้ทางe-mail
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 17:30:09 By : habuu
 


 

No. 22



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

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

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

ขอบอกตรงๆ ว่าโค้ดแบบนี้ เขียนใหม่เร็วกว่าแก้เยอะเลยครับ - -

เขียนซ้ำซ้อน และซับซ้อนเกินกว่าที่ควรจะเป็น

แต่เอามาดูก็ได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 17:40:37 By : cookiephp
 


 

No. 23



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



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


ส่งลิ้งให้ใน pm แล้วค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 17:49:54 By : habuu
 


 

No. 24



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

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

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

เจอที่ผิดแล้วครับ แต่ไม่สามารถอธิบายได้ว่าเพราะอะไร

บรรทัดที่ 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
 


 

No. 25



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

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

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

ผมแก้ให้แค่นี้นะครับ เพราะปัญหาที่คุณติดจริงๆ มันอยู่ตรงนี้
ส่วนการตรวจจำนวนคุณอาจจะทำถูกแล้วก็ได้ ขอให้ลองทำต่อไปครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 18:35:59 By : cookiephp
 


 

No. 26



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



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


ขอบคุณค่ะจะลองแก้ไขดู เพราะตอนนี้ echo $strQ ยังไงค่าก็ไม่ขึ้นเลยค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-25 18:49:07 By : habuu
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยทีค่ะ อยากทำการเช็คจำนวนสินค้ากับ stock ที่มี ถ้าใส่เกิน ให้เด้งเตือนว่า สินค้าไม่พอค่ะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

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