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 > รบกวนคนที่เข้าใจเรื่อง session หรือระบบ ecommerce เข้ามาช่วยอธิบายให้ฟังหน่อยนะค่ะ ถือว่าเป็นวิทยาทานนะค่ะ รบกวนด้วยนะค่ะ



 

รบกวนคนที่เข้าใจเรื่อง session หรือระบบ ecommerce เข้ามาช่วยอธิบายให้ฟังหน่อยนะค่ะ ถือว่าเป็นวิทยาทานนะค่ะ รบกวนด้วยนะค่ะ

 



Topic : 074004

Guest




รบกวนช่วยดูโค๊ดแล้วให้คำแนะนำหน่อยนะค่ะ แก้มาหลายวันแล้ว ไม่เข้าใจอะค่ะ คิดว่ามันน่าจะผิดตรง SESSION

หน้า 1.php แล้ว action ไปที่หน้า cart.php คือ ไปที่หน้า cart แล้ว color กับ propic_id มันทำยังไงถึงจะเรียกใช้ได้ที่ หน้า cart.php ค่ะ

Code
<select name="proColor" class="txtbox">
<option value="">Select color</option>
<?
//=========== Select color from table products_pictures
$sql_group = "select * from products_pictures WHERE pro_id='".$_GET["pro_id"]."' order by propic_id asc";
$dbquery_group = mysql_query($sql_group);
//$num_rows_group = mysql_num_rows($dbquery_group);
while ($result = mysql_fetch_array($dbquery_group))
{
?>
<option value="<?=$result["propic_id"];?>"><?=$result["color"];?></option>
<?
}
?>
</select>



โค๊ดหน้า cart.php

Code (PHP)
if($_GET["pro_id"] != "")
{
	for($i=0;$i<=count($_SESSION["strpro_id"]);$i++)
	{
			if($_SESSION["strpro_id"][$i] == $_GET["pro_id"])
			{
			header("location:$_SERVER[PHP_SELF]");
			exit();
			}
	}
}

//============If user add product this will store these information to Session
if(trim($_GET["pro_id"])!= "")
{
	$_SESSION["strP"]=$_SESSION["strP"]+1;
	$_SESSION["strpro_id"][$_SESSION[strP]]=$_GET["pro_id"];
	$_SESSION["strQuanlity"][$_SESSION[strP]]=1;
	session_write_close();
	header("location:$_SERVER[PHP_SELF]");
}	

//============ If have delete item of purchase
if(trim($_GET["action"]) == "Del")
{
	$_SESSION["strpro_id"][$_GET[P]]="";
	$_SESSION["strQuanlity"][$_GET[P]]="";
	session_write_close();
	header("location:$_SERVER[PHP_SELF]");
}	

//============ If have update purchase item
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('Item # [ $result[ProductCode] ] out of Stock');";
									echo"</script>";	
	}
*/	
	
}	
	session_write_close();
	//============ Jump Refresh one more time
	header("location:$_SERVER[PHP_SELF]");
}	
?>			</td>
      </tr>
      <tr>
        <td><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#f2f2f6" bgcolor="#FFFFFF">
          <tr>
            <td width="17%" valign="top"><?php require_once('menuleft.php'); ?></td>
            <td valign="top"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td align="center"><img src="images/step1.jpg" width="742" height="57" /></td>
              </tr>
              <tr>
                <td height="46" align="center"><span class="style17">Your cart. </span></td>
              </tr>
              <tr>
                
              </tr>
              <tr>
                <td><table width="99%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="right">  <form action="" method="post" name="frmCart" id="frmCart">
					
                      <span class="style18"><strong>
                      </strong></span>
                      <strong>
                      <input name="action" type="hidden" id="action" value="Update" />
                      </strong>
                      <table width="93%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#333333">
                        <tr>
                          <td width="4%" height="33" align="center" bgcolor="#FFFFFF"><span class="style31">No</span></td>
                          <td width="57%" align="center" bgcolor="#FFFFFF"><span class="style31">Detail</span></td>
                          <td width="12%" align="center" bgcolor="#FFFFFF"><span class="style31">Price</span></td>
                          <td width="18%" align="center" bgcolor="#FFFFFF"><span class="style31">Qauntity</span></td>
                          <td width="9%" align="center" bgcolor="#FFFFFF"><span class="style31">Total</span></td>
                        </tr>
                      </table>
                      <table width="93%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#333333">
                        <tr>
                           <?

//============ Show how many item user had select

$strNum=0;
$strTotal=0;
for($i=0;$i<=count($_SESSION["strpro_id"]);$i++)
{
//============ select information from product table
$result=select("products where 1=1 and pro_id='".$_SESSION["strpro_id"]["$i"]."'");
$result2=select("products_pictures where 1=1 and pro_id='".$_SESSION["strpro_id"]["$i"]."'");
//$result=select("products.pro_id,products.pro_name,products.pro_code,products_pictures.pro_id,products_pictures.propic_name from products inner join products_pictures on products.pro_id = products_pictures.pro_id where 1=1 and pro_id='".$_SESSION["strpro_id"]["$i"]."' ");
if($result)
{
$strNum++;
?><td width="5%" height="42" align="center" bgcolor="#FFFFFF"><span class="style26">
                             <?=$strNum;?>
                             <br />                            
                             <a href="javascript:if(confirm('Do you want to remove this item')==true){window.location='<?=$_SERVER['PHP_SELF'];?>?action=Del&amp;P=<?=$i;?>';}"><img src="images/deleteC.gif" width="12" height="11" border="0" /></a>
                             </div>
                           </span></td>
                          <td width="5%" height="42" align="left" valign="middle" bgcolor="#FFFFFF"><a href="#"><span class="style32"><img src="products/<?=$result2["propic_name"];?>" width="36" height="29" border="0" /></span><br />
                          </a></td>
                          <td width="49%" align="left" bgcolor="#FFFFFF"><a href="products.php?progroup_id=<?=$result["progroup_id"];?>"><span class="style32"> (
                                <?=$result["pro_code"];?>
) </span> <span class="style26">
<?=$result["pro_name"];?>
<span class="style32">(
<?=$result2["color"];?>
)</span></span></a></td>
                          <td width="12%" height="42" align="right" bgcolor="#FFFFFF"><span class="style26"><?=$result["price"];?>
                          </span></td>
                          <td width="15%" height="42" align="right" bgcolor="#FFFFFF"><span class="style26">
                            <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;?>');" />
							 <? /*if ($_SESSION["strQuanlity"]["i"]<$result2["stock"]) {
							 echo "<script>";
							 echo "alert('This product(".$result["pro_name"].")are sold');";
        					 echo "</script>";
							     }
								 */
								 
							?>
                            <a href="javascript:if(confirm('Do you want to remove this item')==true){window.location='<?=$_SERVER['PHP_SELF'];?>?action=Del&amp;P=<?=$i;?>';}"><br />
                            </a></span></td>
                          <td width="3%" align="right" bgcolor="#FFFFFF"><span class="style26">/<?=$result["unitcall"];?>
                          </span></td>
                          <td width="11%" height="42" align="right" bgcolor="#FFFFFF"><span class="style26"><?="".number_format(($result["price"]+$result["PriceSend"])*$_SESSION["strQuanlity"]["$i"], 2,'.',',');?>
                          </span></td>
                        </tr> <?
								  $strTotal=$strTotal+(($result["price"])*$_SESSION["strQuanlity"]["$i"]);
}
}
?>
                        
                        <tr>
                          <td bgcolor="#FFFFFF">&nbsp;</td>
                          <td colspan="2" bgcolor="#FFFFFF"><?
							if($strNum==0)
							{
							echo "<br><center><strong><font color=red>YOUR SHOPPING CART IS EMPTY</font></strong></center><br><br>";
							}
							?></td>
                          <td bgcolor="#FFFFFF">&nbsp;</td>
                          <td colspan="2" bgcolor="#FFFFFF">&nbsp;</td>
                          <td bgcolor="#FFFFFF">&nbsp;</td>
                        </tr>
                        <tr>
                          <td colspan="7"></td>
                          </tr>
                      </table>
                      <hr align="center" width="700" color="#f2f2f6" />
                      <br />
                                        <table width="93%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#333333">
                                          <tr>
                                            <td width="81%" align="right" bgcolor="#FFFFFF"><span class="style26"><strong>Total</strong> (item) in your cart   : </span></td>
                                            <td width="19%" bgcolor="#FFFFFF"><?=$strNum;?></td>
                                          </tr>
                                          <tr>
                                            <td align="right" bgcolor="#FFFFFF"><span class="style26">Shipping cost   : </span></td>
                                            <td bgcolor="#FFFFFF">&nbsp;</td>
                                          </tr>
                                          <tr>
                                            <td align="right" bgcolor="#FFFFFF"><span class="style26"><strong>Total : </strong>(US DOLLAR $) </span></td>
                                            <td bgcolor="#FFFFFF"><?="".number_format($strTotal, 2,'.',',');?></td>
                                          </tr>
                                        </table><br />
                                        <table width="93%" border="0" align="center" cellpadding="0" cellspacing="0">
                                          <tr>
                                            <td align="right"><input name="BtnContinute" type="button" class="button" id="BtnContinute2" value="Continue to shopping" onclick="window.location='shopping_index.php';" />
&nbsp;
<?
								  if($strNum>0)
								  {?>
<input name="BtnCalu" type="submit" class="button" id="BtnCalu" value="Caculate" />
&nbsp;
<input name="BtnPayment" type="button" class="button" id="BtnPayment" value="Check out" onclick="window.location='pay.php';" />
<?}?></td>
                                          </tr>
                                        </table>
                                        <hr align="center" width="750" color="#f2f2f6" />
                    </form>                    </td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
            </tr>
           <tr> 
                <td colspan="2" valign="top">
                  <?php require_once('down.php'); ?>                </td>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>


รบกวนคนที่เข้าใจเรื่อง session หรือระบบ ecommerce เข้ามาช่วยอธิบายให้ฟังหน่อยนะค่ะ ถือว่าเป็นวิทยาทานนะค่ะ รบกวนด้วยนะค่ะ



Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-02-17 08:05:53 By : มือใหม่หัดขับ View : 1033 Reply : 5
 

 

No. 1

Guest


ลืมค่ะ อันนี้ form action จากหน้า 1.php

<form action="cart.php?pro_id=<?=$resultDetail["pro_id"];?>" method="post" name="frmNew" id="frmNew" onsubmit="return checkvalue();">






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-17 08:43:39 By : มือใหม่หัดขับ
 


 

No. 2



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



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


session_start() อยู่ไหน


ต้องมี
session_start() อยู่บรรทัดแรกบนสุด
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-17 08:52:40 By : randOmizE
 

 

No. 3

Guest


ใส่แล้วค่ะ ทุกอย่างทำงานได้ ยกเว้น color เราเรียกข้อมูลมาแสดงที่หน้า cart.php จากสองตาราง คือปัญหาของเราคือ จะทำยังไงที่หน้า cart ถ้าเราเรียกข้อมูลมาสองตาราง เราไม่ได้ส่งโค๊ดมาให้ดูหมด ส่งมาเฉพาะส่วนที่เป็นปัญหา

ที่หน้า 1.php

Code (PHP)
<form action="cart.php?pro_id=<?=$resultDetail["pro_id"];?>" method="post" name="frmNew" id="frmNew" onsubmit="return checkvalue();">

<select name="proColor" class="txtbox">
<option value="">Select color</option>
<?
//=========== Select color from table products_pictures
$sql_group = "select * from products_pictures WHERE pro_id='".$_GET["pro_id"]."' order by propic_id asc";
$dbquery_group = mysql_query($sql_group);
//$num_rows_group = mysql_num_rows($dbquery_group);
while ($result = mysql_fetch_array($dbquery_group))
{
?>
<option value="<?=$result["propic_id"];?>"><?=$result["color"];?></option>
<?
}
?>
</select>


ที่หน้า cart.php โค๊ดอยู่ที่หัวข้อกระทู้นะค่ะ คือเราดึงข้อมูลมาจากสองตาราง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-17 09:23:20 By : มือใหม่หัดขับ
 


 

No. 4



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



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


ปัญหาคือ color ไม่ออกอะไรหรอครับ? ที่ select จาก db
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-17 10:08:14 By : randOmizE
 


 

No. 5

Guest


คือทุกอย่างทำงานได้หมดค่ะ แต่พอส่งไปที่หน้า cart.php เราต้องการให้มันส่ง propic_id ไปด้วยอะ แต่ตอนนี้มันไปแค่ pro_id
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-17 14:32:11 By : มือใหม่หัดขับ
 

   

ค้นหาข้อมูล


   
 

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