⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 show.asp

📁 fger th t ytwety w4t qrt 43 q34rt5 q34t3q4t
💻 ASP
字号:
<HTML><HEAD><TITLE>体育用品专卖店</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<STYLE type=text/css>
<!--
td{font-size:10pt;font-family:宋体; line-height:14pt; font-family:宋体;}
A:link	{text-decoration: underline; color:"#000000"}
A:visited  {text-decoration: underline; color: "#000090"}
A:active {text-decoration: none; color: #0000FF }
A:hover {text-decoration: none; color: #ff0000 }
.class1{background-color:#eeeeee;border-style:solid;border-color:#6666cc;border-width:1;}
-->
</STYLE>
</HEAD>
<BODY background="" bgColor=#ffffff text=#000000 topMargin=0 leftmargin="30" style="font:10pt">
<TABLE border=0 cellPadding=0 cellSpacing=0 width=500>
<TR><td>
<!-- ************ 核心asp文件的开始 ************* -->
<!--#INCLUDE file="config.inc" -->
<%
'此函数用来规范sql查询语句
   function sqlstr(data)
     sqlstr="'" & Replace(data,"'","''") & "'"
   end function

Dim iPageSize       '每页放置多少条记录
Dim pagetotal       '根据ipagesize计算所得总页数
Dim iPageCurrent    '需要显示的页面
Dim sSQL            '执行查询的sql语句
Dim lngUserSessionId
lngUserSessionId = Session.SessionID

'判断这是一个新的用户连接打开的show.asp页面,还是由于用户单击“上一页”按钮、“下一页”按钮等来请求的页面。如果是一个新的请求,程序需要对于一些变量加以初始化。例如:将记录用户是否已经连接的Session变量值标记为已经连接状态;将每页显示的记录条数初始化为config.inc中定义的数量,而如果不是一个新的请求,那么判断该页面是从用户请求当前页面的另一页中产生。如果是用户在自定义每页显示记录条数的文本框中输入了数值并且提交了表单,程序必须要判断该用户提交的数值是否合法。如果合法,则按照把该数值设置为每页显示记录条数的新值。
if isempty(session("isconnected")) then
   session("isconnected")=true
   ipagesize=pagesize
else
   ipagesize=trim(request.form("ipagesize"))
   if ipagesize="" or not isnumeric(ipagesize) or ipagesize="0" then
      iPageSize = session("pagesize") '用户可以改变每页显示记录数
   end if
end if

'如果用户发出的是一个新的连接请求,则ipagesize当前值是pagesize,即为config.inc中预定义的记录每页显示多少条记录的已知常量,并把该数据记录到Session变量Session("pagesize")中;如果用户发出的不是一个新的连接请求,则ipagesize记录的是用户通过修改每页显示记录条数的文本框的值。这个值如果不合法,经过上段程序判断的结果,ipagesize被重新赋予原来存储在Session("pagesize")中的值;如果这个值合法,则将该合法值重新记录到Session("pagesize")变量中。

session("pagesize")=ipagesize

'这里处理的是用户选择的显示页面。通过“上一页”、“下一页”或者直接在浏览器地址拦中入带页数参数的URL来请求处理。
'如果URL中传递的页面参数为空,则设置为第一页;如果不为空,则把该参数赋予记录将要显示页面的变量。
If Request.QueryString("page") = "" Then
	iPageCurrent = 1
Else
	iPageCurrent = CInt(Request.QueryString("page"))
End If

'连接数据库,打开商品表和小类查询
 Set Conn = Server.CreateObject("ADODB.Connection")
 Conn.Open ConnString 

 Set objproductRS = Server.CreateObject("ADODB.Recordset")
 Set objkindRS = Server.CreateObject("ADODB.Recordset")

 objproductrs.activeConnection= Conn  
 objkindRS.activeConnection= Conn  

   sqlstr1= "SELECT * FROM Product;"
   sqlstr2= "SELECT * FROM Productkind;"

  objproductrs.Open sqlstr1
  objkindRS.Open sqlstr2

  ' 如果记录指针指向文件末尾标识,则表明该表是空的,暂且还没有任何数据。
  if objproductrs.eof then
     response.write "对不起,目前没有搜索到您要求的数据!"
	 response.end   ' 由于数据库中没有该类的商品,则后面的程序都不需要执行
  end if
  objproductRS.movefirst

 ' 获取用户从导航栏程序中所选择要显示的商品种类。这个参数通过URL传递到该程序。
 ' 如果用户是从浏览器地址栏中输入该URL并且其小类参数为空,则将小类值设置为当前数据指针所在记录的商品的小类。
  kindchoice = request.QueryString("choice")
  if kindchoice = "" then
  kindchoice = objkindrs("kind") 
  end if 
   ' 从数据库表中抽取出此种类的记录集
	set objkindtotalrs=server.createobject("adodb.recordset")
	sql="select * from product where kind=" & sqlstr(kindchoice)
	objkindtotalrs.open sql,conn,1,3
	'下面的if语句用来计算显示商品所需要的总页面数
    objkindtotalrs.pagesize=ipagesize
	pagetotal=objkindtotalrs.pagecount
' 如果所需要显示的页面不在范围之内,则需要进行溢出处理
If iPageCurrent > pagetotal Then iPageCurrent = pagetotal
If iPageCurrent < 1 Then iPageCurrent = 1

'记录当前的商品小类和所在页面数
Session("page")= ipageCurrent
Session("productkind")= kindchoice

'如果没有此类商品
If pagetotal = 0 Then
	Response.Write "<br><br><center><font class=normal>对不起,目前没有您要的商品!</font></center><hr color=#999933 size=1>"
	response.end
Else

' 下面开始显示页面
%>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=2 WIDTH="500" >
<TR VALIGN=TOP>
<td>
<%
  response.write "<form name=""ipsize"" action=""show.asp"" method=post>"
  response.write "<font color=""#ff0000"" class=normal>您的位置:商品浏览>" & kindchoice & "</font>"

'显示当前页面和总页面
response.write "&nbsp;&nbsp;&nbsp;页码:"
for page=1 to pagetotal
  if page=ipagecurrent then
     response.write "<font color=#CC00FF>"& page & "></font>"
  else %>
  <font color=#009900>
   <A HREF="show.asp?page=<%=page%>&choice=<%=kindchoice%>"><%=page%></A>></font>
<%end if
next
response.write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
%>
<!-- 这里提供一个文本框,用户可以在其中输入自定义的每页显示记录条数 -->
	<font class=normal>每页显示记录&nbsp;</font><input type=text size=2 name=ipagesize>
	<br><hr color=#009900 width="100%">
	</form>	<%
'下面的表单,用来提供给用户选择该商品,并且将该商品信息加入到自己的购物车中。
'需要传递一系列参数,这些参数反映了该商品的一般描述信息
%>
	  <form action="cart.asp" method="post">      
<%
     '将所选种类记录集的记录指针移到当前页面
     objkindtotalrs.absolutepage=ipagecurrent
	 '计算前面所有页面的记录数
     count1=(Cint(ipagecurrent)-1)*objkindtotalrs.pagesize
     i = 1 '变量,记录当前页面上记录指针的移动位置
	 do while (i<=objkindtotalrs.pagesize)
         if i+count1>objkindtotalrs.recordcount then
           exit do   '如果指针已经移动到objkindtotalrs记录集的末尾,则退出循环
         else
		      '打印表格,显示商品记录
		      response.Write "<TABLE CELLSPACING=1 CELLPADDING=0 width= ""400"" BORDER=""0"">" 
			  response.Write "<tr><td></td><td></td><td align=left rowspan=6 width=""150"">" 
		      if objkindtotalrs("photo") <> "" then
                 response.Write "<img src=" & objkindtotalrs("photo") & "  border=""1"">" 
			  else 
			     response.write "<img src=""image/noimage.gif"" width=""100"">" 
              end if
	          response.Write "</tr><tr><td align=right width=100>商品名:</td><td align=left width=""200"">" 
		      response.write objkindtotalrs("name")
	          response.Write "</TD></tr>"
			  response.write "<tr><td align=right>商品品牌:</td><td align=left width=""200"">"
			  response.write objkindtotalrs("nametag")
              response.Write "<tr><td align=right>优惠价格:</td><td align=left width=""200"">" 
              response.Write objkindtotalrs("price") & "&nbsp;$"
              response.Write "</td></tr><tr><td align=right valign=top>商品简介:</td><td align=left width=""200"">" 
              response.Write objkindtotalrs("description") 
		      response.Write "</TD>"
              response.write "</tr><tr>"
              response.write "<td align=right>放入购物车</td><td align=center>" 
              val=CInt(i + firststart)
              response.write "&nbsp;"
		      %>
<!-- 下面的黑体部分是将该商品的4种信息通过URL传递给pushcart.asp程序进行处理,并且将该程序显示在一个弹出式窗口之中。-->
	<img src="image/cart.gif" name="cart" style="cursor:hand" onclick="window.open('pushcart.asp?productid=<%=objkindtotalrs("productid")%>&productname=<%=objkindtotalrs("name")%>&price=<%=objkindtotalrs("price")%>&photo=<%=objkindtotalrs("photo")%>','_blank','toolbars=no,scrollbars=no,width=500,height=350')">
  <%
	  response.Write "</td></tr></TABLE><hr width=""100%"" color=#003399 size=1>" 
  end if
      objkindtotalrs.movenext  '记录指针下移
   i=i+1  
	 loop '结束循环显示
End If  '  结束商品显示
 response.write "</TD></TR></TABLE>"

'清空变量,关闭数据库
Set objproductrs = Nothing
set objkindrs=nothing
set objkindtotalrs=nothing
Conn.Close
Set Conn = Nothing
%>
</TR>
<tr> <td></td></tr></table>
</BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -