<?
@session_start();
require('system/inc/db_conn.php');
require('inc/pageft.php');
$conn = $db->conn_open();
if($_SESSION["login_status"]==""|| $_SESSION["login_status"]== false)
{
echo("<script>alert('Please Register or Login ');history.go(-1)</script>");
}
?>
<?
if($_REQUEST["act"]=="del")
{$id = $_REQUEST['id'];
$sql = "delete from shop_cart where id='$id'";
$result = $db->query($sql,$conn);
if($result){
echo("<script>location.href='cart_list.php'</script>");
}else{
echo("<script>alert('Delete Failure');location.href='cart_list.php'</script>");
}}if($_REQUEST["act"]=="gx")
{
$pid=explode(',',$_REQUEST["allcheckboxs"]);for($i=0;$i<count($pid);$i++)
{
$bnum=$_REQUEST["carnumber".$pid[$i]];
$sql="update shop_cart set carnumber=$bnum where id=$pid[$i]";
$sql2="update shop_cart set total=carnumber*productprice where id=$pid[$i]";
$result=$db->query($sql,$conn);
$result2=$db->query($sql2,$conn);
}
echo"<script>location.href='cart_list.php'</script>";
}
?>
<!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" />
<LINK href="images/css.css" type=text/css rel=stylesheet>
<title>Shopping Cart</title>
<script language="javascript">
function allcheckbox()
{
document.myform.elements["allcheckboxs"].value = "";
if ( !document.myform.elements["checkbox1"].length ) // 只有一个复选框,form3.checkbox1.length = undefined
{
if ( document.myform.elements["checkbox1"].checked )
document.myform.elements["allcheckboxs"].value = document.myform.elements["checkbox1"].value;
}
else
{
for ( i = 0 ; i < document.myform.elements["checkbox1"].length ; i++ )
{
if ( document.myform.elements["checkbox1"][i].checked ) // 复选框中有选中的框
{
document.myform.elements["allcheckboxs"].value = document.myform.elements["checkbox1"][i].value;
for ( j = i + 1 ; j < document.myform.elements["checkbox1"].length ; j++ )
{
if ( document.myform.elements["checkbox1"][j].checked )
{
document.myform.elements["allcheckboxs"].value += ","; //用,做分割符
document.myform.elements["allcheckboxs"].value +=document.myform.elements["checkbox1"][j].value;
}
}
break;
}
}
} return true; }</script>
</head><body>
<?require"top.php";
?>
<table width="1002" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="200" height="658" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="200" height="384" align="left" valign="top"> <? require("left.php");?></td>
</tr>
</table></td>
<td width="16"> </td>
<td width="786" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="786" height="127" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="786" height="127" valign="top"><div id="slideimg">
<script language="JavaScript" type="text/javascript">
var focus_width=786 /*幻灯片新闻图片宽度*/
var focus_height=127 /*幻灯片新闻图片高度*/
var text_height=0 /*幻灯片新闻文字标题高度*/
var swf_height = focus_height+text_height var pics = '';
var links = '';
var texts = ''; function ati(url, img, title)
{
if(pics != '')
{
pics = "|" + pics;
links = "|" + links;
texts = "|" + texts;
} pics = escape(img) + pics;
links = escape(url) + links;
texts = title + texts;
}
</script>
<script language="JavaScript" type="text/javascript">
var barcode=new Array(4) ;
var bannerurl=new Array(4) ;
barcode[0]='images/js004.jpg';bannerurl[0]='#';barcode[1]='images/js002.jpg';bannerurl[1]='#';barcode[2]='images/js005.jpg';bannerurl[2]='#';barcode[3]='images/js003.jpg';bannerurl[3]='#';
ati(bannerurl[0], barcode[0], '');
ati(bannerurl[1], barcode[1], '');
ati(bannerurl[2], barcode[2], '');
ati(bannerurl[3], barcode[3], '');
document.write('<embed src="images/pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#DADADA" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"/>');
</script>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="9"></td>
</tr>
<tr>
<td height="511" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="786" height="511" align="left" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="29" background="images/new_arrived1B.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="81%" height="29" align="left" class="one"> Shopping Cart</td>
<td width="19%" align="center" class="che"> </td>
</tr>
</table></td>
</tr>
</table> <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px dotted #cccccc;">
<!--DWLayoutTable-->
<tr>
<td width="15" height="16"> </td>
<td width="758"> </td>
<td width="11"> </td>
</tr>
<tr>
<td height="448"> </td>
<td align="left" valign="top">内容在太长分二页
@session_start();
require('system/inc/db_conn.php');
require('inc/pageft.php');
$conn = $db->conn_open();
if($_SESSION["login_status"]==""|| $_SESSION["login_status"]== false)
{
echo("<script>alert('Please Register or Login ');history.go(-1)</script>");
}
?>
<?
if($_REQUEST["act"]=="del")
{$id = $_REQUEST['id'];
$sql = "delete from shop_cart where id='$id'";
$result = $db->query($sql,$conn);
if($result){
echo("<script>location.href='cart_list.php'</script>");
}else{
echo("<script>alert('Delete Failure');location.href='cart_list.php'</script>");
}}if($_REQUEST["act"]=="gx")
{
$pid=explode(',',$_REQUEST["allcheckboxs"]);for($i=0;$i<count($pid);$i++)
{
$bnum=$_REQUEST["carnumber".$pid[$i]];
$sql="update shop_cart set carnumber=$bnum where id=$pid[$i]";
$sql2="update shop_cart set total=carnumber*productprice where id=$pid[$i]";
$result=$db->query($sql,$conn);
$result2=$db->query($sql2,$conn);
}
echo"<script>location.href='cart_list.php'</script>";
}
?>
<!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" />
<LINK href="images/css.css" type=text/css rel=stylesheet>
<title>Shopping Cart</title>
<script language="javascript">
function allcheckbox()
{
document.myform.elements["allcheckboxs"].value = "";
if ( !document.myform.elements["checkbox1"].length ) // 只有一个复选框,form3.checkbox1.length = undefined
{
if ( document.myform.elements["checkbox1"].checked )
document.myform.elements["allcheckboxs"].value = document.myform.elements["checkbox1"].value;
}
else
{
for ( i = 0 ; i < document.myform.elements["checkbox1"].length ; i++ )
{
if ( document.myform.elements["checkbox1"][i].checked ) // 复选框中有选中的框
{
document.myform.elements["allcheckboxs"].value = document.myform.elements["checkbox1"][i].value;
for ( j = i + 1 ; j < document.myform.elements["checkbox1"].length ; j++ )
{
if ( document.myform.elements["checkbox1"][j].checked )
{
document.myform.elements["allcheckboxs"].value += ","; //用,做分割符
document.myform.elements["allcheckboxs"].value +=document.myform.elements["checkbox1"][j].value;
}
}
break;
}
}
} return true; }</script>
</head><body>
<?require"top.php";
?>
<table width="1002" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="200" height="658" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="200" height="384" align="left" valign="top"> <? require("left.php");?></td>
</tr>
</table></td>
<td width="16"> </td>
<td width="786" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="786" height="127" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="786" height="127" valign="top"><div id="slideimg">
<script language="JavaScript" type="text/javascript">
var focus_width=786 /*幻灯片新闻图片宽度*/
var focus_height=127 /*幻灯片新闻图片高度*/
var text_height=0 /*幻灯片新闻文字标题高度*/
var swf_height = focus_height+text_height var pics = '';
var links = '';
var texts = ''; function ati(url, img, title)
{
if(pics != '')
{
pics = "|" + pics;
links = "|" + links;
texts = "|" + texts;
} pics = escape(img) + pics;
links = escape(url) + links;
texts = title + texts;
}
</script>
<script language="JavaScript" type="text/javascript">
var barcode=new Array(4) ;
var bannerurl=new Array(4) ;
barcode[0]='images/js004.jpg';bannerurl[0]='#';barcode[1]='images/js002.jpg';bannerurl[1]='#';barcode[2]='images/js005.jpg';bannerurl[2]='#';barcode[3]='images/js003.jpg';bannerurl[3]='#';
ati(bannerurl[0], barcode[0], '');
ati(bannerurl[1], barcode[1], '');
ati(bannerurl[2], barcode[2], '');
ati(bannerurl[3], barcode[3], '');
document.write('<embed src="images/pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#DADADA" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"/>');
</script>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="9"></td>
</tr>
<tr>
<td height="511" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="786" height="511" align="left" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="29" background="images/new_arrived1B.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="81%" height="29" align="left" class="one"> Shopping Cart</td>
<td width="19%" align="center" class="che"> </td>
</tr>
</table></td>
</tr>
</table> <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px dotted #cccccc;">
<!--DWLayoutTable-->
<tr>
<td width="15" height="16"> </td>
<td width="758"> </td>
<td width="11"> </td>
</tr>
<tr>
<td height="448"> </td>
<td align="left" valign="top">内容在太长分二页
<form action="?act=gx" method="post" name="myform" id="myform" onsubmit="allcheckbox()">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="bian3">
<!--DWLayoutTable-->
<tr>
<td height="51" colspan="6" align="left" valign="top" style="border-bottom:2px #e3e3e1 dotted;"><img src="images/cartnavi-1.gif" width="599" height="49" /></td>
</tr> <tr>
<td height="25" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/2menubg.gif">
<!--DWLayoutTable-->
<tr>
<td width="131" height="25" align="center" valign="middle"><strong>Photo</strong></td>
<td width="193" align="center" valign="middle">Product Name</td>
<td width="126" align="center" valign="middle">Price($)</td>
<td width="117" align="center" valign="middle">Amount</td>
<td width="89" align="center" valign="middle">Subtotal</td>
<td width="39"> </td>
</tr>
</table></td>
</tr>
<?
$sql="select c.*,p.Class_photoa,p.sortid from shop_cart c,sq_class p where class_id=productid and userid =".$_SESSION['user_id']." and ordertype=1";
$result=$db->query($sql,$conn);
$row=$db->num_rows($result);
$tmoney=0;
for ($i=0;$i<$row;$i++){
$rs=$db->fetch_array($result,MYSQL_BOTH);
$tmoney=$tmoney+$rs["total"];
?>
<tr>
<td width="130" height="160" valign="top"><img src="<?=$rs["Class_photoa"]?>" width="130" height="160" border="0" /></td>
<td width="196" align="center" valign="middle"> <input name="checkbox1" type="checkbox" id="checkbox1" value="<?=$rs["id"]?>" checked="checked" style="display:none"/><?=$rs["productname"]?></td>
<td width="123" align="center" valign="middle"><?=$rs["productprice"]?></td>
<td width="116" align="center" valign="middle"><label>
<input name="carnumber<?=$rs["id"]?>" type="text" class="textf" id="carnumber" value="<?=$rs["carnumber"]?>" size="4" maxlength="4"/>
</label></td>
<td width="87" align="center" valign="middle"><?=$rs["total"]?></td>
<td width="43" align="center" valign="middle"><a href="?act=del&id=<?=$rs["id"]?>"><img src="images/b-delete.gif" width="39" height="22" border="0" /></a></td>
</tr>
<?
}
?>
<tr>
<td height="127" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-top:2px #d2eafc solid;">
<!--DWLayoutTable-->
<tr>
<td width="285" height="50"> </td>
<td width="58"> </td>
<td width="352" align="right" valign="bottom" class="Price"><strong>Subtotal:<?=$tmoney?>
$</strong></td>
</tr>
<tr>
<td height="29"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="47"><!--DWLayoutEmptyCell--> </td>
<td align="right" valign="middle"><!--DWLayoutEmptyCell--> </td>
<td align="right" valign="middle"><a href="Products.php"><span class="productListing-data">
<input name="allcheckboxs" type="hidden" />
</span><img src="images/cart_continue.gif" width="103" height="23" border="0" /></a>
<input type="image" src="images/cart_change.gif" name="Submit" value="提交" />
<a href="cart3.php"><img src="images/cart_next.gif" width="103" height="23" border="0" /></a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="69"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
</td>
<td> </td>
</tr>
<tr>
<td height="14"> </td>
<td> </td>
<td> </td>
</tr> </table></td>
</tr> </table></td>
</tr>
<tr>
<td height="11"></td>
</tr> </table></td>
</tr>
</table>
<? require"end.php";?>
@session_start();
require('system/inc/db_conn.php');
require('inc/pageft.php');
$conn = $db->conn_open();
if($_SESSION["login_status"]==""|| $_SESSION["login_status"]== false)
{
echo("<script>alert('Please Register or Login ');history.go(-1)</script>");
}
?>
<?
if($_REQUEST["act"]=="del")
{$id = $_REQUEST['id'];
$sql = "delete from shop_cart where id='$id'";
$result = $db->query($sql,$conn);
if($result){
echo("<script>location.href='cart_list.php'</script>");
}else{
echo("<script>alert('Delete Failure');location.href='cart_list.php'</script>");
}}if($_REQUEST["act"]=="gx")
{
$pid=explode(',',$_REQUEST["allcheckboxs"]);for($i=0;$i<count($pid);$i++)
{
$bnum=$_REQUEST["carnumber".$pid[$i]];
$sql="update shop_cart set carnumber=$bnum where id=$pid[$i]";
$sql2="update shop_cart set total=carnumber*productprice where id=$pid[$i]";
$result=$db->query($sql,$conn);
$result2=$db->query($sql2,$conn);
}
echo"<script>location.href='cart_list.php'</script>";
}
?>
<script language="javascript">
function allcheckbox()
{
document.myform.elements["allcheckboxs"].value = "";
if ( !document.myform.elements["checkbox1"].length ) // 只有一个复选框,form3.checkbox1.length = undefined
{
if ( document.myform.elements["checkbox1"].checked )
document.myform.elements["allcheckboxs"].value = document.myform.elements["checkbox1"].value;
}
else
{
for ( i = 0 ; i < document.myform.elements["checkbox1"].length ; i++ )
{
if ( document.myform.elements["checkbox1"][i].checked ) // 复选框中有选中的框
{
document.myform.elements["allcheckboxs"].value = document.myform.elements["checkbox1"][i].value;
for ( j = i + 1 ; j < document.myform.elements["checkbox1"].length ; j++ )
{
if ( document.myform.elements["checkbox1"][j].checked )
{
document.myform.elements["allcheckboxs"].value += ","; //用,做分割符
document.myform.elements["allcheckboxs"].value +=document.myform.elements["checkbox1"][j].value;
}
}
break;
}
}
} return true; }</script>
<form action="?act=gx" method="post" name="myform" id="myform" onsubmit="allcheckbox()">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="bian3">
<!--DWLayoutTable-->
<tr>
<td height="51" colspan="6" align="left" valign="top" style="border-bottom:2px #e3e3e1 dotted;"><img src="images/cartnavi-1.gif" width="599" height="49" /></td>
</tr> <tr>
<td height="25" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/2menubg.gif">
<!--DWLayoutTable-->
<tr>
<td width="131" height="25" align="center" valign="middle"><strong>Photo</strong></td>
<td width="193" align="center" valign="middle">Product Name</td>
<td width="126" align="center" valign="middle">Price($)</td>
<td width="117" align="center" valign="middle">Amount</td>
<td width="89" align="center" valign="middle">Subtotal</td>
<td width="39"> </td>
</tr>
</table></td>
</tr>
<?
$sql="select c.*,p.Class_photoa,p.sortid from shop_cart c,sq_class p where class_id=productid and userid =".$_SESSION['user_id']." and ordertype=1";
$result=$db->query($sql,$conn);
$row=$db->num_rows($result);
$tmoney=0;
for ($i=0;$i<$row;$i++){
$rs=$db->fetch_array($result,MYSQL_BOTH);
$tmoney=$tmoney+$rs["total"];
?>
<tr>
<td width="130" height="160" valign="top"><img src="<?=$rs["Class_photoa"]?>" width="130" height="160" border="0" /></td>
<td width="196" align="center" valign="middle"> <input name="checkbox1" type="checkbox" id="checkbox1" value="<?=$rs["id"]?>" checked="checked" style="display:none"/><?=$rs["productname"]?></td>
<td width="123" align="center" valign="middle"><?=$rs["productprice"]?></td>
<td width="116" align="center" valign="middle"><label>
<input name="carnumber<?=$rs["id"]?>" type="text" class="textf" id="carnumber" value="<?=$rs["carnumber"]?>" size="4" maxlength="4"/>
</label></td>
<td width="87" align="center" valign="middle"><?=$rs["total"]?></td>
<td width="43" align="center" valign="middle"><a href="?act=del&id=<?=$rs["id"]?>"><img src="images/b-delete.gif" width="39" height="22" border="0" /></a></td>
</tr>
<?
}
?>
<tr>
<td height="127" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-top:2px #d2eafc solid;">
<!--DWLayoutTable-->
<tr>
<td width="285" height="50"> </td>
<td width="58"> </td>
<td width="352" align="right" valign="bottom" class="Price"><strong>Subtotal:<?=$tmoney?>
$</strong></td>
</tr>
<tr>
<td height="29"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="47"><!--DWLayoutEmptyCell--> </td>
<td align="right" valign="middle"><!--DWLayoutEmptyCell--> </td>
<td align="right" valign="middle"><a href="Products.php"><span class="productListing-data">
<input name="allcheckboxs" type="hidden" />
</span><img src="images/cart_continue.gif" width="103" height="23" border="0" /></a>
<input type="image" src="images/cart_change.gif" name="Submit" value="提交" />
<a href="cart3.php"><img src="images/cart_next.gif" width="103" height="23" border="0" /></a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="69"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
把数量echo出来,然后再对照数据库,找原因;