📄 basket.jsp
字号:
<%@ page contentType="text/html;charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<link href=css.css rel=STYLESHEET type=text/css>
<jsp:useBean id="mdb" class="ckstudio.db.faq" scope="page"/>
<%@ include file="inc/conn1.jsp"%>
<title>
<%!
int Cint(String cint)
{
try {
int n;
n= Integer.parseInt(cint);
return n;
}
catch (NumberFormatException e) {
return 0;
}
}
%>
<%!
String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{
e.printStackTrace();
return null;
}
}
%>
<%
String user_name=(String)session.getValue("user_name");
if(user_name!=null)
{
%>
<%=user_name%>的购物车
<%
}else
{
out.print("购物车");
}%>
</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body><font color="#000000"><b>
<%
String hw_cashs,basket_count,hw_name,hw_id;
int hw_cash,count;
String jiage;
int totalcash=0;
int daili=0;
if(user_name==null)
{
out.print( "1.你尚未登录!请登录后再订购本站商品!");
out.print("<br>2.第一次来本站,请先注册会员(免费)!");
%>
<a href=# onClick="javascript:window.close();">关闭窗口</a>
<%
}
else
{//having login check
String hw_ids=request.getParameter("id");
//String shuid=request.getParameter("id");
//hw_id exists or not--------------------------------------------------------------
hw_ids.trim();
sql="select * from tushumingxi where shuID="+hw_ids;
rs=stmt.executeQuery(sql);
while(rs.next())
{
//result showing begin ------------------------------------------
daili=rs.getInt("dingjia");
hw_name=rs.getString("shu_name");
%>
<br>
<table border="0" width="400" cellspacing="0" cellpadding="0">
<form method="POST" action="buy.jsp?action=buy&hw_id=<%=hw_ids%>&hw_name=<%=hw_name%>&hw_cash=<%=daili%>>
<tr>
<td align="center" bgcolor="#DBC2B0">
<img border="0" src="img/promo_list_top.gif" width="100%" height="4"></td></tr>
<tr>
<td height="18" align="center" bgcolor="#DBC2B0">所选购的商品信息</td></tr>
<tr bgcolor="#FFFFFF">
<td width="398" bgcolor="#F5EFE7">
<div align="center">
<center>
<table width="90%" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
<tr background="img/pics/tile_bg.gif">
<td width="155" height="25"> <div align="center">商品名称</div></td>
<td width="60" height="25"> <div align="center">商品单价</div></td>
<td width="60" height="25"> <div align="center">订购数量</div></td>
<td width="80" height="25"> <div align="center">确认购买</div></td>
</tr>
<tr>
<td width="155" height="30"> <div align="center"><%=hw_name%></div></td>
<td width="60" height="30"> <div align="center">
<%=daili%> 元</div></td>
<td width="60" height="30"> <div align="center">
<select size="1" name="count">
<%for(int i=0;i<=10;i++){
%>
<option><%=i%></option>
<%}
%>
</select>
</div></td>
<td width="80" height="30"><div align="center">
<input name=B1 type=image id="B1"
src="image/ok.gif" alt=í???
align=absMiddle width="45" height="20" cache tppabs="">
</div></td>
</tr>
</table>
</center>
</div></tr>
<tr>
<td height="30" valign="top" bgcolor="#F5EFE7"><table width="83%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="33%"><a href="buy.jsp"><img src="image/lookbcar.gif" width="100" height="20" border="0"></a></td>
<td width="33%"><a href="clear.jsp"><img src="image/relbcar.gif" width="100" height="20" border="0"></a></td>
<td width="33%"><a href="cash.jsp"><img src="image/gobuy.gif" width="100" height="20" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center">
<img border="0" src="img/promo_list_top.gif" width="100%" height="4"></td>
</tr>
<tr>
<td height="18" align="center" bgcolor="#DBC2B0">你已选购的商品如下</td>
</tr>
<p>
<% }//result showing end ------------------------------------------
rs.close();
//hw_id exist check end------------------------------------------------------------
}//login or not check end
%>
</p>
<tr><td>
<table border="0" width="100%" cellspacing="0" height="34" cellpadding="0">
<tr>
<td width="398" bgcolor="#F5EFE7">
<div align="center">
<table width="90%" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
<tr background="img/pics/tile_bg.gif">
<td width="155" height="25"> <div align="center">商品名称</div></td>
<td width="80"> <div align="center">商品单价</div></td>
<td width="80"> <div align="center">订购数量</div></td>
<td width="80"> <div align="center">订购时间</div></td>
<td width="80"> <div align="center">合计</div></td>
</tr>
<%
sql="select * from basket where user_name='"+user_name+"'";
rs=stmt.executeQuery(sql);
while(rs.next())
{
hw_cashs=rs.getString("hw_cash");
basket_count=rs.getString("basket_count");
hw_name=rs.getString("hw_name");
jiage=rs.getString("daili");
count=1;
%>
<tr>
<td width="155" height="25"> <div align="center"><a href="clear.jsp?basket_id=<%=rs.getInt("basket_id")%>"></a><%=hw_name%></div></td>
<td width="65" height="25"> <div align="center">
<%=jiage%>元</div></td>
<td width="65" height="25"> <div align="center"><%=basket_count%>
</div></td>
<td width="65" height="25"> <div align="center"> <%=rs.getDate("basket_date")%>
</div></td>
<td width="65" height="25"> <div align="center">
<%=Cint(jiage)*Cint(basket_count)%> 元 </div></td>
<%totalcash=totalcash+Cint(jiage)*Cint(basket_count);%>
</tr>
<%
}
%>
<tr>
<td width="321" height="25" colspan="4"><div align="center">总计:</div></td>
<td width="65" height="25"><div align="center">
<%=totalcash%>元</div></td>
</table>
<table width="100%" height="25" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="middle"><div align="center"><img src="img/pics/seperator.gif" width="359" height="1"></div></td>
</tr>
</table>
</div></td>
<td width="14" valign="top" bgcolor="#F5EFE7"><div align="right"></div></td>
</tr>
</table>
</td></tr> </form>
</table>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -