📄 viewcart.php
字号:
<?php
session_start();
?>
<html>
<head>
<title>InterShop-View Shopping Cart</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../style.css">
<script language=javascript>
function view(id)
{
var arg= "width=500,height=400,resizable=no,scrollbars=yes,status=0,top=0,left=0";
window.open ("itemdetail.php?ItemID="+ id ,"a",arg);
}
function docheckone()
{
var alen=document.frmList.elements.length;
var isChecked=true;
alen=(alen>5)?document.frmList.chkid.length:0;
if (alen>0)
{
for(var i=0;i<alen;i++)
if(document.frmList.chkid[i].checked==false)
isChecked=false;
}else
{
if(document.frmList.chkid.checked==false)
isChecked=false;
}
document.frmList.chkall.checked=isChecked;
}
function docheck(status,from_)
{
var alen=document.frmList.elements.length;
alen=(alen>5)?document.frmList.chkid.length:0;
if (alen>0)
{
for(var i=0;i<alen;i++)
document.frmList.chkid[i].checked=status;
}else
{
document.frmList.chkid.checked=status;
}
if(from_>0)
document.frmList.chkall.checked=status;
}
function checkInput()
{
var alen=document.frmList.elements.length;
var isChecked=false;
alen=(alen>5)?document.frmList.chkid.length:0;
if (alen>0)
{
for(var i=0;i<alen;i++)
if(document.frmList.chkid[i].checked==true)
isChecked=true;
}else
{
if(document.frmList.chkid.checked==true)
isChecked=true;
}
if (!isChecked)
alert("Please select at least one of them");
else
calculatechon();
return isChecked;
}
function calculatechon()
{
var strchon="";
var alen=document.frmList.elements.length;
alen=(alen>5)?document.frmList.chkid.length:0;
if (alen>0)
{
for(var i=0;i<alen;i++)
if(document.frmList.chkid[i].checked==true)
strchon+=document.frmList.chkid[i].value+",";
}else
{
if(document.frmList.chkid.checked==true)
strchon=document.frmList.chkid[i].value;
}
document.frmList.chkids.value=strchon;
}
</script>
</head>
<body >
<form action="preorder.php" method="post" name="frmList" onsubmit="return checkInput();">
<table width="500" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td valign="top" >
<?php
if(session_is_registered("cart"))
{
require("../dbcon.inc");
$items=$cart;
$items=str_replace (",", "','", $items);
$wh=" and (activate=1 and ItemID in ('";
$wh .=$items."'))";
$sortby=" order by ItemName";
$totalRows = 0;
$paging="";
$stSQL ="select ItemID,ItemName,AuthName,";
$stSQL .="Price from tblBooks, tblauthors ";
$stSQL .="where tblBooks.AuthID= ";
$stSQL .= "tblauthors.AuthID ".$wh;
$stSQL.=$sortby;
//echo $stSQL;
$result = mysql_query($stSQL, $link);
$totalRows=mysql_num_rows($result);
}
?>
<table border="0" width="100%">
<tr><td align=left><h2>Your Shopping Cart
</h2></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="middle" valign="top" >
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="center">
<td width="5%" height="14" align="middle"><font face="Arial" color="#ff6600">No</font></td>
<td width="10%" height="14">
<?php
if(session_is_registered("cart"))
{?>
<input type="checkbox" name="chkall" value="0" onclick="docheck(document.frmList.chkall.checked,0);" checked>
<?php
}?>
</td>
<td width="29%" height="14"><font face="Arial" color="#ff6600">Item Name</font></td>
<td width="10%" height="14"><font face="Arial" color="#ff6600">
Quantity</font></td>
<td width="12%" height="14"><font face="Arial" color="#ff6600">Price</font></td>
<td width="25%" height="14">
<div><font face="Arial" color="#ff6600">Author Name</font></div>
</td>
</tr>
<tr valign="top">
<td colspan="7" align="middle">
<hr noshade size="1">
</td>
</tr>
<?php
if(session_is_registered("cart"))
{
if($totalRows>0 && session_is_registered("cart"))
{
$i=0;
$strid="";
while ($row = mysql_fetch_array ($result))
{
$itemid=$row["ItemID"];
$strid .=$itemid.",";
$itemname=$row["ItemName"];
$authname=$row["AuthName"];
$price=$row["Price"];
$i+=1;
?>
<tr valign="top">
<td align="middle"><font face="Arial" color="#0066cc">
<?=$i?>
</font> </td>
<td ><font face="Arial" color="#0066cc">
<input type=checkbox name="chkid" checked value="<?=$itemid?>" onclick="docheckone();">
</font></td>
<td ><font face="Arial" color="#0066cc"><A href="javascript:view('<?=$itemid?>');">
<?=$itemname?>
</A></font></td>
<td ><font face="Arial" color="#0066cc">
<input type=text name="txtqtty<?=$itemid?>" size=2 maxlength=5 value="1" class=textbox>
</font></td>
<td ><font face="Arial" color="#0066cc">
<?=$price?>
</font></td>
<td><font face="Arial" color="#0066cc">
<?=$authname?>
</font>
</td>
</tr>
<?php
}
?>
<tr valign="top">
<td colspan="7" align="middle">
<hr noshade size="1">
</td>
</tr>
<tr valign="top">
<td width="5%" align="middle"> </td>
<td colspan=6 valign=center>
<input type=submit value="Continue" class=button>
<input type=button value="Back" onlick="history.go(-1);" class=button>
<input type=hidden value="<?=$strid?>" name="chkids">
</td>
</tr>
<?php
}
}
else{
?>
<tr valign="top">
<td width="5%" align="middle"> </td>
<td colspan=6 valign=center align="center"><b><font face="Arial" color="#FF0000">Oop!
There is not Items in your cart! please add to shopping cart at least one.</font></b></td>
</tr>
<tr valign="top">
<td colspan="7" align="middle">
<hr noshade size="1">
</td>
</tr>
<tr valign="top">
<td width="5%" align="middle"> </td>
<td colspan=6 valign=center>
<input type=button value="Back" onlick="history.go(-1);" class=button>
</td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -