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

HOME > PHP > PHP Forum > ดูตะกร้าสินค้าให้หน่อยครับค่าน้ำหนักมันคำนวนแถวล่าสุดแค่แถวเดียวแล้วก็วนซ้ำไปเรื่อยๆ



 

ดูตะกร้าสินค้าให้หน่อยครับค่าน้ำหนักมันคำนวนแถวล่าสุดแค่แถวเดียวแล้วก็วนซ้ำไปเรื่อยๆ

 



Topic : 069552

Guest




ช่วยดูหน่อยนะครับติดมาหลายวันแล้ว

add_product.php เปลี่ยนเป็น array
<?

session_start();


$id=$_GET[id];
$qty=$_GET[qty];
echo "$qty";


if(count($sess_id)=="0"){
$check=1;

}else if (!in_array($id,$sess_id)){
$check=1;
}

if($check==1){

include("conn.inc.php");
$sql="select * from tb_product where  p_nameid ='$id' ";
$result=mysql_query($sql);
$rs=mysql_fetch_array($result);
 

$_SESSION['sess_id'][]=$rs[p_nameid];
$_SESSION['sess_name'][]=$rs[pro_name];
$_SESSION['sess_price'][]=$rs[pro_price];
$_SESSION['sess_type'][]=$rs[type_name];
$_SESSION['sess_num'][]=1;
$_SESSION['sess_service']=500;
$_SESSION['sess_qty'][]=$rs[pro_qty];
$_SESSION['sess_weight'][]=$rs[pro_weight];



}

echo"<meta http-equiv=\"refresh\" content=\"0;URL=?do=cart\" />"; 
               


?>


code cart คำนวนสินค้า
<?
session_start();
?>

<!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>เธ•เธฃเธฐเธเธฃเน‰เธฒเธชเธดเธ™เธ„เน‰เธฒ</title>
<link href="normal_font.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.style6 {
	font-size: 16px;
	color: #FFF;
}
.style13 {color: #FF0000}
.style19 {color: #CCFF33}
-->
</style>

<!--javaเธ„เธณเธ™เธงเธ™
-->
<script language="javascript">
	function CheckSubmit()
	{
	form1.submit();
	}
</script>


</head>

<body>
<table width="574" align="center">
  <tr>
    
    <td width="573" valign="top" bgcolor="#FFFFFF"><span class="style6">
<?  
      
		                     
 $sess_id=$_SESSION['sess_id'];
 $sess_name=$_SESSION['sess_name'];
 $sess_price=$_SESSION['sess_price']; 
 $sess_type=$_SESSION['sess_type']; 
 $sess_num=$_SESSION['sess_num']; 
 $sess_service=$_SESSION['sess_service']; 
 $sess_weight=$_SESSION['sess_weight'];         อันนี้คือน้ำหนัก
 
    
?>
      <strong>
    
 <?
        
if(count($sess_id)==0){ 
       
?>
      </strong><font color="#FF0000">เธขเธฑเธ‡เน„เธกเนˆเธกเธตเธชเธดเธ™เธ„เน‰เธฒเนƒเธ™เธ•เธฐเธเธฃเน‰เธฒเธชเธดเธ™เธ„เน‰เธฒเธ‚เธญเธ‡เธ—เนˆเธฒเธ™เธ„เธฃเธฑเธš <a href="index.php" title="เน€เธฅเธทเธญเธเธ‹เธทเน‰เธญเธชเธดเธ™เธ„เน‰เธฒ">เธ„เธฅเธดเธเธ—เธตเนˆเธ™เธตเนˆ</a><strong><strong><a href="index.php" title="เน€เธฅเธทเธญเธเธ‹เธทเน‰เธญเธชเธดเธ™เธ„เน‰เธฒ"></a> </strong></strong>เน€เธžเธทเนˆเธญเน€เธฅเธทเธญเธเธ‹เธทเน‰เธญเธชเธดเธ™เธ„เน‰เธฒเธ™เนˆเธฐเธ„เธฃเธฑเธš<strong><strong>
      <?
         
}else{ 
         
?>
      </strong></strong></font></span>
      <form method="post" action="script_calculate.php" name="form1">
      <table width="572" cellpadding="0" cellspacing="1" >
          <tr align="center" bgcolor="#000000" class="normal_font">
            <td width="5%" height="22" bgcolor="#666666" class="style6">เธฅเธš</td>
            <td width="15%" bgcolor="#666666"><span class="style6">เธฃเธซเธฑเธชเธชเธดเธ™เธ„เน‰เธฒ</span></td>
            <td width="17%" bgcolor="#666666" class="style6">เธ›เธฃเธฐเน€เธ เธ—เธชเธดเธ™เธ„เน‰เธฒ</td>
            <td width="21%" bgcolor="#666666" class="style6">เธชเธดเธ™เธ„เน‰เธฒ</td>
            <td width="10%" bgcolor="#666666" class="style6">เธˆเธณเธ™เธงเธ™</td>
            <td width="15%" bgcolor="#666666" class="style6">เธฃเธฒเธ„เธฒ / เธซเธ™เนˆเธงเธข </td>
            <td width="17%" colspan="2" bgcolor="#666666" class="style6">เธฃเธงเธก (เธšเธฒเธ—) </td>
          </tr>
<?
              
for($i=0;$i<count($sess_id);$i++){ 
$total_unit=$sess_num[$i]*$sess_price[$i]; 
$total=$total_unit + $total;                                    
$sum=$total+$sess_service; 
$code=sprintf("%05d",$sess_id[$i]); 
 
$summ1 = $sess_weight[$i] * $sess_num[$i];
$summ = $summ + $summ1; มันติดตรงนี้แหละคับ

$_SESSION['summ'] = $summ;   
              
?>
          <tr align="center">
            <td><input name="p_del[]" type="checkbox" id="p_del[]" value="<?=$sess_id[$i]?>" ></td>
            <td><?=$sess_id[$i]?>
            <p>&nbsp;</p></td>
            <td height="22"><?=$sess_type[$i]?>
            <p>&nbsp;</p></td>
            <td><?=$sess_name[$i]?> 
            <p><input type="text" value="<?=$summ1;?>" id="sumweg"></p></td>
            <td><p>
              <input name="prd_num[]" type="text"  style="text-align:center"  value="<?=$sess_num[$i]?>" size="5"  />
            </p>
            <p>&nbsp; </p></td>
            <td "><? echo number_format($sess_price[$i],2);?>
            <p>&nbsp;</p></td>
            <td><p><span name="spnSum1" id="spnSum1"><? echo number_format($total_unit,2);?></span></p>
            <p>&nbsp;</p></td>
          </tr>
         
<?
            
}


     
?>
          <tr>
            <td colspan="8" align="right" class="normal_font"><?=$_SESSION['summ']; ?>เธฃเธฒเธ„เธฒเธฃเธงเธกเธชเธดเธ™เธ„เน‰เธฒเธ—เธฑเน‰เธ‡เธซเธกเธ” <strong><span class="style13"><? echo number_format($total,2);?></span></strong> เธšเธฒเธ— </td>
          </tr>
          <tr>
            <td height="22" colspan="8" align="right">
			<input name="calculate" type="submit"  value="เธ„เธณเธ™เธงเธ“เนƒเธซเธกเนˆ"  style="background:url(images/preeson1.png); width:100; height:70;"/>
              <input name="continuebuy"  type="button" id="continuebuy" onclick="window.location='index.php' " value="เน€เธฅเธทเธญเธเธ‹เธทเน‰เธญเธชเธดเธ™เธ„เน‰เธฒเน€เธžเธดเนˆเธก" style="background:url(images/preeson1.png); width:100; height:70;"/>
              <input name="complete" type="button" class="style13" id="complete" onclick="window.location='?do=order' " value="เธชเธฑเนˆเธ‡เธ‹เธทเน‰เธญเธชเธดเธ™เธ„เน‰เธฒ" style="background:url(images/preeson1.png); width:100; height:70;"/></td>
          </tr>
        </table>
	 
	<?
   }
   ?>
	  </form> 
    </td>
  </tr>
</table>
<br />
</body>
</html>





Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-11-25 17:53:07 By : hixor View : 915 Reply : 4
 

 

No. 1

Guest


ไม่มีคนช่วยดูเลยแหะ

ค่าน้ำหนักมันมันคิดแค่แถวล่าสุดแถวเดียวแล้วก็ทบไปเรื่อยๆไม่รู้จะแก้ยังไง TT






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-11-26 14:07:19 By : hixor
 


 

No. 2

Guest


$_SESSION['summ'] = $summ; อยู่ในลูปfor
ค่าสุดท้ายในลูปจึงถูกเก็บไว้ใน$_SESSION['summ']
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-11-26 16:35:31 By : เสือ เลิศคณิตกรณ์
 

 

No. 3



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

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

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

อันนี้ครับ

Code (PHP)
<?
session_start();
?>

<!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=windows-874" />
<title>เธ&bull;เธฃเธฐเธเธฃเน‰เธฒเธชเธดเธ™เธ„เน‰เธฒ</title>
<link href="normal_font.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.style6 {
	font-size: 16px;
	color: #FFF;
}
.style13 {color: #FF0000}
.style19 {color: #CCFF33}
-->
</style>

<!--javaเธ„เธณเธ™เธงเธ™
-->
<script language="javascript">
	function CheckSubmit()
	{
	form1.submit();
	}
</script>


</head>

<body>
<table width="574" align="center">
  <tr>
    
    <td width="573" valign="top" bgcolor="#FFFFFF"><span class="style6">
<?  
      
		                     
 $sess_id=$_SESSION['sess_id'];
 $sess_name=$_SESSION['sess_name'];
 $sess_price=$_SESSION['sess_price']; 
 $sess_type=$_SESSION['sess_type']; 
 $sess_num=$_SESSION['sess_num']; 
 $sess_service=$_SESSION['sess_service']; 
 $sess_weight=$_SESSION['sess_weight'];         อันนี้คือน้ำหนัก
 
    
?>
      <strong>
    
 <?
        
if(count($sess_id)==0){ 
       
?>
      </strong><font color="#FF0000">เธขเธฑเธ‡เน„เธกเนˆเธกเธตเธชเธดเธ™เธ„เน‰เธฒเนƒเธ™เธ&bull;เธฐเธเธฃเน‰เธฒเธชเธดเธ™เธ„เน‰เธฒเธ‚เธญเธ‡เธ&mdash;เนˆเธฒเธ™เธ„เธฃเธฑเธš <a href="index.php" title="เน€เธฅเธทเธญเธเธ‹เธทเน‰เธญเธชเธดเธ™เธ„เน‰เธฒ">เธ„เธฅเธดเธเธ&mdash;เธตเนˆเธ™เธตเนˆ</a><strong><strong><a href="index.php" title="เน€เธฅเธทเธญเธเธ‹เธทเน‰เธญเธชเธดเธ™เธ„เน‰เธฒ"></a> </strong></strong>เน&euro;เธžเธทเนˆเธญเน&euro;เธฅเธทเธญเธเธ‹เธทเน‰เธญเธชเธดเธ™เธ„เน‰เธฒเธ™เนˆเธฐเธ„เธฃเธฑเธš<strong><strong>
      <?
         
}else{ 
         
?>
      </strong></strong></font></span>
      <form method="post" action="script_calculate.php" name="form1">
      <table width="572" cellpadding="0" cellspacing="1" >
          <tr align="center" bgcolor="#000000" class="normal_font">
            <td width="5%" height="22" bgcolor="#666666" class="style6">เธฅเธš</td>
            <td width="15%" bgcolor="#666666"><span class="style6">เธฃเธซเธฑเธชเธชเธดเธ™เธ„เน‰เธฒ</span></td>
            <td width="17%" bgcolor="#666666" class="style6">เธ›เธฃเธฐเน&euro;เธ&nbsp;เธ&mdash;เธชเธดเธ™เธ„เน‰เธฒ</td>
            <td width="21%" bgcolor="#666666" class="style6">เธชเธดเธ™เธ„เน‰เธฒ</td>
            <td width="10%" bgcolor="#666666" class="style6">เธˆเธณเธ™เธงเธ™</td>
            <td width="15%" bgcolor="#666666" class="style6">เธฃเธฒเธ„เธฒ / เธซเธ™เนˆเธงเธข </td>
            <td width="17%" colspan="2" bgcolor="#666666" class="style6">เธฃเธงเธก (เธšเธฒเธ&mdash;) </td>
          </tr>
<?
              
for($i=0;$i<count($sess_id);$i++){ 
$total_unit=$sess_num[$i]*$sess_price[$i]; 
$total=$total_unit + $total;                                    
$sum=$total+$sess_service; 
$code=sprintf("%05d",$sess_id[$i]); 
 
$summ1 = $sess_weight[$i] * $sess_num[$i];
$summ = $summ + $summ1; มันติดตรงนี้แหละคับ

$_SESSION['summ'] = $summ;   
              
?>
          <tr align="center">
            <td><input name="p_del[]" type="checkbox" id="p_del[]" value="<?=$sess_id[$i]?>" ></td>
            <td><?=$sess_id[$i]?>
            <p>&nbsp;</p></td>
            <td height="22"><?=$sess_type[$i]?>
            <p>&nbsp;</p></td>
            <td><?=$sess_name[$i]?> 
            <p><input type="text" value="<?=$summ1;?>" id="sumweg"></p></td>
            <td><p>
              <input name="prd_num[]" type="text"  style="text-align:center"  value="<?=$sess_num[$i]?>" size="5"  />
            </p>
            <p>&nbsp; </p></td>
            <td "><? echo number_format($sess_price[$i],2);?>
            <p>&nbsp;</p></td>
            <td><p><span name="spnSum1" id="spnSum1"><? echo number_format($total_unit,2);?></span></p>
            <p>&nbsp;</p></td>
          </tr>
         
          <tr>
            <td colspan="8" align="right" class="normal_font"><?=$_SESSION['summ']; ?>เธฃเธฒเธ„เธฒเธฃเธงเธกเธชเธดเธ™เธ„เน‰เธฒเธ&mdash;เธฑเน‰เธ‡เธซเธกเธ" <strong><span class="style13"><? echo number_format($total,2);?></span></strong> เธšเธฒเธ&mdash; </td>
          </tr>
<?
            
}


     
?>
          <tr>
            <td height="22" colspan="8" align="right">
			<input name="calculate" type="submit"  value="เธ„เธณเธ™เธงเธ"เนƒเธซเธกเนˆ"  style="background:url(images/preeson1.png); width:100; height:70;"/>
              <input name="continuebuy"  type="button" id="continuebuy" onclick="window.location='index.php' " value="เน€เธฅเธทเธญเธเธ‹เธทเน‰เธญเธชเธดเธ™เธ„เน‰เธฒเน€เธžเธดเนˆเธก" style="background:url(images/preeson1.png); width:100; height:70;"/>
              <input name="complete" type="button" class="style13" id="complete" onclick="window.location='?do=order' " value="เธชเธฑเนˆเธ‡เธ‹เธทเน‰เธญเธชเธดเธ™เธ„เน‰เธฒ" style="background:url(images/preeson1.png); width:100; height:70;"/></td>
          </tr>
        </table>
	 
	<?
   }
   ?>
	  </form> 
    </td>
  </tr>
</table>
<br />
</body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-11-26 16:41:53 By : Dragons_first
 


 

No. 4

Guest


เพิ่ม

$summ2 +=$summ;
เปลี่ยน $_SESSION['summ'] = $summ2;

ได้แล้วๆๆๆๆ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-11-26 16:57:01 By : hixor
 

   

ค้นหาข้อมูล


   
 

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

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

Notice

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

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







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

Load balance : Server 05
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 อัตราราคา คลิกที่นี่