|
|
|
ช่วยแก้โค้ตAdd cart ให้หน่อยนะคับ ใกล้สอบแล้ว ช่วยที่นะคับ |
|
|
|
|
|
|
|
Code (PHP)
<?
session_start();
$id=$_GET[id];
if(count($sess_id)=="0"){
$check=1;
}else if (!in_array($id,$sess_id)){
$check=1;
}
if($check==1){
include "connect.php";
$sql="select * from tb_product where p_id='$id' ";
$result=mysql_db_query($dbname,$sql);
$rs=mysql_fetch_array($result);
$_SESSION['sess_id']=$rs[p_id];
$_SESSION['sess_name']=$rs[p_name];
$_SESSION['sess_price']=$rs[p_price];
$_SESSION['sess_type']=$rs[p_type];
$_SESSION['sess_num']=1;
}
header("Location:cart.php");
?>
หน้า cart
<?
session_start();
include "function2.php";
?>
<!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;
}
-->
</style></head>
<body>
<? include "head_user.php" ?><br />
<table width="940" align="center">
<tr>
<th width="150" align="left" valign="top" scope="row"><span class="normal_font">
<? include "login_user.php"?>
</span></th>
<td align="center" valign="top">
<p>
<table width="670" border="0" cellspacing="0" cellpadding="0">
<?
$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']=1;
?>
<tr>
<td align="left">
<form action="" method="post" name="calculate" id="calculate">
<?
if(count($sess_id)==0){
?>
<tr>
<td height="25" align="center"><strong><font color="#FF0000">ยังไม่มีสินค้าในตะกร้าสินค้าของท่านค่ะ</font& gt;</strong><br />
<br />
<a href="index2.php" title="เลือกซื้อสินค้า">คลิกที่นี่</a> เพื่อเลือกซื้อสินค้า </td>
</tr>
<?
}else{
?>
<table width="744" cellpadding="0" cellspacing="1" bordercolor="#FF9FAA">
<tr align="center" bgcolor="#FF9FAA" class="normal_font">
<td width="3%" height="22"><strong>ลบ</strong></td>
<td width="12%"><strong>รหัสสินค้า</strong></td>
<td width="17%"><strong>ประเภทสินค้า</strong></td>
<td width="21%"><strong>สินค้า</strong></td>
<td width="11%"><strong>จำนวน</strong></td>
<td width="21%"><strong>ราคา</strong></td>
<td width="15%" colspan="2"><strong>รวม</strong></td>
</tr>
<?php
for($i=0;$i<count($sess_id);$i++){
$total_unit=$sess_num*$sess_price;
$total=$total+$total_unit;
?>
<tr align="center">
<td><input name="id_del[]" type="checkbox" id="id_del[]" value="<?=$sess_id?>" /></td>
<td> <?=$sess_id?></td>
<td height="22"><?=$sess_type?></td>
<td><?=$sess_name?></td>
<td><input name="prd_num[]" type="text" id="prd_num[]" value="<?=$sess_num?>" size="5" maxlength="3" style="text-align:center"></td>
<td><? echo number_format($sess_price,2);?></td>
<td><? echo number_format($total_unit,2);?></td>
</tr>
<tr>
<td height="22" colspan="6" align="right"> </td>
<td colspan="2" align="center"> </td>
</tr>
<tr class="normal_font">
<td height="22" colspan="6" align="right"><strong>ราคารวมทั้งหมด</strong></td>
<td colspan="2" align="center"><strong><font color="#FF0000"><? echo number_format($total,2);?></font> บาท </strong></td>
</tr>
<tr>
<td height="22" colspan="8" align="right"> </td>
</tr>
<?
}
?>
<tr>
<td height="22" colspan="8" align="right"><input name="calculate" type="submit" id="calculate" value="คำนวณราคาสินค้า" />
<input name="continuebuy" type="button" id="continuebuy" onclick="window.location='index2.php' " value="ซื้อสินค้าต่อ" />
<input name="complete" type="submit" id="complete" value="ยืนยันสั่งซื้อสินค้า" /></td>
</tr>
<?
}
?>
</table>
</form>
</body>
</html>
Tag : PHP, MySQL, HTML/CSS, JavaScript, VBScript, CakePHP
|
|
|
|
|
|
Date :
2011-09-27 21:07:38 |
By :
charnuwat |
View :
754 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
session_start();
$id=$_GET[id];
if(count($sess_id)=="0"){
$check=1;
}else if (!in_array($id,$sess_id)){
$check=1;
}
if($check==1){
include "connect.php";
$sql="select * from tb_product where p_id='$id' ";
$result=mysql_db_query($dbname,$sql);
$rs=mysql_fetch_array($result);
$_SESSION['sess_id']=$rs[p_id];
$_SESSION['sess_name']=$rs[p_name];
$_SESSION['sess_price']=$rs[p_price];
$_SESSION['sess_type']=$rs[p_type];
$_SESSION['sess_num']=1;
}
header("Location:cart.php");
?>
หน้า cart
<?
session_start();
include "function2.php";
?>
<!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;
}
-->
</style></head>
<body>
<? include "head_user.php" ?><br />
<table width="940" align="center">
<tr>
<th width="150" align="left" valign="top" scope="row"><span class="normal_font">
<? include "login_user.php"?>
</span></th>
<td align="center" valign="top">
<p>
<table width="670" border="0" cellspacing="0" cellpadding="0">
<?
$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']=1;
?>
<tr>
<td align="left">
<form action="" method="post" name="calculate" id="calculate">
<?
if(count($sess_id)==0){
?>
<tr>
<td height="25" align="center"><strong><font color="#FF0000">ยังไม่มีสินค้าในตะกร้าสินค้าของท่านค่ะ</font& gt;</strong><br />
<br />
<a href="index2.php" title="เลือกซื้อสินค้า">คลิกที่นี่</a> เพื่อเลือกซื้อสินค้า </td>
</tr>
<?
}else{
?>
<table width="744" cellpadding="0" cellspacing="1" bordercolor="#FF9FAA">
<tr align="center" bgcolor="#FF9FAA" class="normal_font">
<td width="3%" height="22"><strong>ลบ</strong></td>
<td width="12%"><strong>รหัสสินค้า</strong></td>
<td width="17%"><strong>ประเภทสินค้า</strong></td>
<td width="21%"><strong>สินค้า</strong></td>
<td width="11%"><strong>จำนวน</strong></td>
<td width="21%"><strong>ราคา</strong></td>
<td width="15%" colspan="2"><strong>รวม</strong></td>
</tr>
<?php
for($i=0;$i<count($sess_id);$i++){
$total_unit=$sess_num*$sess_price;
$total=$total+$total_unit;
?>
<tr align="center">
<td><input name="id_del[]" type="checkbox" id="id_del[]" value="<?=$sess_id?>" /></td>
<td> <?=$sess_id?></td>
<td height="22"><?=$sess_type?></td>
<td><?=$sess_name?></td>
<td><input name="prd_num[]" type="text" id="prd_num[]" value="<?=$sess_num?>" size="5" maxlength="3" style="text-align:center"></td>
<td><? echo number_format($sess_price,2);?></td>
<td><? echo number_format($total_unit,2);?></td>
</tr>
<tr>
<td height="22" colspan="6" align="right"> </td>
<td colspan="2" align="center"> </td>
</tr>
<tr class="normal_font">
<td height="22" colspan="6" align="right"><strong>ราคารวมทั้งหมด</strong></td>
<td colspan="2" align="center"><strong><font color="#FF0000"><? echo number_format($total,2);?></font> บาท </strong></td>
</tr>
<tr>
<td height="22" colspan="8" align="right"> </td>
</tr>
<?
}
?>
<tr>
<td height="22" colspan="8" align="right"><input name="calculate" type="submit" id="calculate" value="คำนวณราคาสินค้า" />
<input name="continuebuy" type="button" id="continuebuy" onclick="window.location='index2.php' " value="ซื้อสินค้าต่อ" />
<input name="complete" type="submit" id="complete" value="ยืนยันสั่งซื้อสินค้า" /></td>
</tr>
<?
}
?>
</table>
</form>
</body>
</html>
|
|
|
|
|
Date :
2011-09-27 21:08:28 |
By :
charnuwat |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยแก้ให้หน่อยนะคับ
|
|
|
|
|
Date :
2011-09-27 21:09:01 |
By :
charnuwat |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|