sql1 = "select * from ProClass order by id"
set rs1 = server.CreateObject("adodb.recordset")
rs1.open sql1,conn,1,1
const MaxPerPage=9
dim totalPut,CurrentPage,TotalPages
end if
strFileName="productList.asp?classId="&rs1("id")
if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if
<%
dim rs,sql
dim classId
dim i_1
i_1=0
classId = request("classId")
sql = "select a.id,ClassName,proName,proImage from product a,proClass b where a.proClassId=b.id and a.proClassId="&classId
set rs = server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.Write "还没有产品!"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"条数据"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"条数据"
else
currentPage=1
showContent
showpage strFileName,totalput,MaxPerPage,true,true,"条数据"
end if
end if
set rs=Nothing
sub showContent()
dim i
i=0
%>
<table width="100%" height="20" border="0" cellpadding="2" cellspacing="2">
<tr>
<%
do while not rs.eof
i_1=i_1+1
%>
<td height="16" align="center"><table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td align="center"><table width="131" border="0" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC" onmouseover="this.style.backgroundColor='#FF4FAE'" onmouseout="this.style.backgroundColor=''">
<tr>
<td bgcolor="#FFFFFF"><img src="<%=rs("proImage")%>" width=131 height=89 border=0 align=absmiddle></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center"><div align="center" onClick="MM_openBrWindow('productView.asp?id=<%=rs("id")%>','','scrollbars=yes,width=500,height=400')"><a href="#"><%=rs("proName")%></a></div></td>
</tr>
</table></td>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
if i_1 mod 3 = 0 then
response.write "</tr><tr>"
end if
loop
rs.close
set rs=nothing
%>
</tr>
</table>
<%end sub%>
<%end if%>
'**************************************************
'函数名:JoinChar
'作 用:向地址中加入 ? 或 &
'参 数:strUrl ----网址
'返回值:加了 ? 或 & 的网址
'**************************************************
function JoinChar(strUrl)
if strUrl="" then
JoinChar=""
exit function
end if
if InStr(strUrl,"?")<len(strUrl) then
if InStr(strUrl,"?")>1 then
if InStr(strUrl,"&")<len(strUrl) then
JoinChar=strUrl & "&"
else
JoinChar=strUrl
end if
else
JoinChar=strUrl & "?"
end if
else
JoinChar=strUrl
end if
end function
'**************************************************
'过程名:showpage
'作 用:显示“上一页 下一页”等信息
'参 数:sfilename ----链接地址
' totalnumber ----总数量
' maxperpage ----每页数量
' ShowTotal ----是否显示总数量
' ShowAllPages ---是否用下拉列表显示所有页面以供跳转。有某些页面不能使用,否则会出现JS错误。
' strUnit ----计数单位
'**************************************************
sub showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
dim n, i,strTemp,strUrl
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
strTemp= "<table align='center'><tr><td><font size='2'>"
if ShowTotal=true then
strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & " "
end if
strUrl=JoinChar(sfilename)
if CurrentPage<2 then
strTemp=strTemp & "首页 上一页 "
else
strTemp=strTemp & "<a href='" & strUrl & "page=1'>首页</a> "
strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage-1) & "'>上一页</a> "
end if
if n-currentpage<1 then
strTemp=strTemp & "下一页 尾页"
else
strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage+1) & "'>下一页</a> "
strTemp=strTemp & "<a href='" & strUrl & "page=" & n & "'>尾页</a>"
end if
strTemp=strTemp & " 页次:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
strTemp=strTemp & " <b>" & maxperpage & "</b>" & strUnit & "/页"
if ShowAllPages=True then
strTemp=strTemp & " 转到:<select name='page' size='1' onchange=""javascript:window.location='" & strUrl & "page=" & "'+this.options[this.selectedIndex].value;"">"
for i = 1 to n
strTemp=strTemp & "<option value='" & i & "'"
if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
strTemp=strTemp & ">第" & i & "页</option>"
next
strTemp=strTemp & "</select>"
end if
strTemp=strTemp & "</font></td></tr></table>"
response.write strTemp
end sub