![]() |
#2
jsxhyj2013-08-07 21:52
这是我参考的网上的,但是我的我还是找不到错在什么地方,高手指点下吧
<!--#include file="conn.asp" --> <% set rs = server.createobject("adodb.recordset") sql = "select * from [表名]" rs.open sql,conn,1,1 '-------只需要改动这3个地方----------- rs.pagesize = 10 '每页显示条数 const Pname="p" '当前页变量名 UrlParam="&keyword=关键词&class=深圳" 'Url条件参数 '------------------------------------- GETpage=trim(request(""&Pname&"")) if GETpage<>"" then page = int(GETpage) if page<1 then page = 1 if page>rs.pagecount then page = rs.pagecount else page = 1 end if rs.absolutepage = page '设置当前页等于page for i = 0 to rs.pagesize -1 '循环显示数据 if rs.eof then exit for '如果到记录集末尾则退出for循环 response.write(rs("lid")&"<br>") rs.movenext '记录集下移一行 next %> <%'------------------------------------------------------ call FenYe(page,rs.pagecount,rs.pagesize,pname,UrlParam) '调用函数 '------------------------------------------------------%> <% function FenYe(Page,MaxCount,Psize,Pname,UrlParam) 'Page为当前点击页,MaxCount为记录集总条数,Psize为每页显示条数,Pname为当前页变量名,UrlParam为Url参数 Page=Cint(Page) '输出首页 上一页 if Page<2 then response.write "首页" response.write "上一页" else response.write "<a href =?"&Pname&"=1"&UrlParam&">首页</a> " response.write "<a href =?"&Pname&"="&Page-1&UrlParam&">上一页</a> " end if '输出数字分页部分,如果不需要数字分页,可删掉 if Page>Psize-1 and MaxCount >Psize then if (Page+int((Psize-1)/2))>MaxCount then PageNow = MaxCount - Psize+1 else PageNow = Page - int((Psize-1)/2) end if for i = 1 to Psize response.write "<a href=?"&Pname&"="&PageNow&UrlParam&">"&PageNow&"</a> " PageNow = PageNow + 1 next else if MaxCount < Psize then for i = 1 to MaxCount response.write "<a href=?"&Pname&"="&i&UrlParam&">"&i&"</a> " next else for i = 1 to Psize response.write "<a href=?"&Pname&"="&i&UrlParam&">"&i&"</a> " next end if end if '输出下一页 尾页 if Page>=MaxCount then response.write "下一页 " response.write "尾页" else response.write "<a href = ?"&Pname&"="&Page+1&UrlParam&">下一页</a> " response.write "<a href = ?"&Pname&"="&MaxCount&UrlParam&">尾页</a>" end if end function %> |

<%
bigclass=request.QueryString("bigclass")
smallclass=request.QueryString("smallclass")
if smallclass="" then
set rs_small=server.createobject("adodb.recordset")
sqltext4="select * from smallclass_new where bigclassname='"&bigclass&"' order by idpx asc"
rs_small.open sqltext4,conn,1,1
smallclass=rs_small("smallclassname")
rs_small.close
set rs_small=nothing
end if
%>
<html>
<TITLE><%if smallclass="" then%><%=bigclass%><%else%><%=smallclass%><%end if%> - <%=SiteTitle%></TITLE>
<head>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<meta name="description" content="<%=Sitedescription%>">
<meta name="keywords" content="<%=Sitekeywords%>">
<!-- #include file="Head.asp" -->
<table width="992" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td background="images_pic/bg.jpg"><table width="972" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="208" align="left" valign="top"><table width="190" border="0" cellpadding="0" cellspacing="0" class="allp">
<tr>
<td height="30" class="left_lm"><%=bigclass%></td>
</tr>
<tr>
<td><%
set rs_news=server.createobject("adodb.recordset")
sqltext4="select * from smallclass_new where bigclassname='"&bigclass&"' order by idpx asc"
rs_news.open sqltext4,conn,1,1
do while not rs_news.EOF
%><a href="news.asp?bigclass=<%=server.URLEncode(rs_news("bigclassname"))%>&smallclass=<%=server.URLEncode(rs_news("smallclassname"))%>" class="leftnav<%if rs_news("smallclassname")=smallclass then%>_h<%end if%>"><%=rs_news("smallclassname")%></a>
<%
rs_news.MoveNext
loop
rs_news.close
set rs_news=nothing
%>
</td>
</tr>
</table>
<!-- #include file="left.asp" -->
</td>
<td width="764" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#e5e5e5"><span class="wz">您的当前位置:<a href="<%=SiteUrl%>" title="<%=SiteName%>" class="hui">首页</a> > <a href="news.asp?bigclass=<%=server.URLEncode(bigclass)%>" title="<%=bigclass%>" class="hui"><%=bigclass%></a> > <%=smallclass%></span><span class="fentitle"><%=smallclass%></span></td>
</tr>
<tr>
<td class="content"><table width="744" border="0" cellpadding="0" cellspacing="0">
<%
page=clng(request("page"))
Set rs=Server.CreateObject("ADODB.RecordSet")
if BigClass<>"" and SmallClass <>"" then
sql="select * from news where BigClassName='"&BigClass&"' and SmallClassName='"&SmallClass&"' order by idpx desc"
rs.Open sql,conn,1,1
elseif BigClass<>"" then
sql="select * from news where BigClassName='"&BigClass&"' order by idpx desc"
rs.Open sql,conn,1,1
end if
if rs.eof and rs.bof then
response.Write("暂时没有记录")
else
%>
<%
rs.PageSize=15
if page=0 then page=1
pages=rs.pagecount
if page > pages then page=pages
rs.AbsolutePage=page
for j=1 to rs.PageSize
%>
<tr>
<td width="23" height="35" align="center" class="downxu" ><span class="downdian"><img src="images_pic/biaod.gif" width="4" height="6" /></span></td>
<td width="589" class="downxu"><a href="info.asp?id=<%= RS("id") %>" title="<%=rs("title")%>" class="font14px" style="<%if rs("color1")<>"" then%>color:<%=rs("color1")%>;<%end if%><%if rs("ztcu")="1" then%>font-weight: bold;<%end if%>"><%=rs("title")%></a></td>
<td width="132" align="right" class="downxu"><font class="adddate"><%=FormatDateTime(RS("AddDate"),2)%></font></td>
</tr>
<%
rs.movenext
if rs.eof then exit for
next
%>
<tr valign="bottom">
<td height="50" colspan="3" align="right" ><form method="post" action="news.asp?BigClass=<%=BigClass%>&SmallClass=<%=SmallClass%>">
<%if Page<2 then
response.write "首页 上一页 "
else
response.write "<a href=news.asp?BigClass="&BigClass&"&SmallClass="&SmallClass&"&page=1>首页</a> "
response.write "<a href=news.asp?BigClass="&BigClass&"&SmallClass="&SmallClass&"&page=" & Page-1 & ">上一页</a> "
end if
if rs.pagecount-page<1 then
response.write "下一页 尾页"
else
response.write "<a href=news.asp?BigClass="&BigClass&"&SmallClass="&SmallClass&"&page=" & (page+1) & ">"
response.write "下一页</a> <a href=news.asp?BigClass="&BigClass&"&SmallClass="&SmallClass&"&page="&rs.pagecount&">尾页</a>"
end if
response.write " 页次:<strong><font color=red>"&Page&"</font>/"&rs.pagecount&"</strong>页 "
response.write " 共<b><font color='#FF0000'>"&rs.recordcount&"</font></b>条记录 <b>"&rs.pagesize&"</b>条记录/页"
response.write " 转到:<input type='text' name='page' size=3 maxlength=5 class=input value="&page&">"
response.write " <input class=input type='submit' value='Go' name='cndok'></span></p>"
%>
</form></td>
</tr>
<%
end if
rs.close
set rs=nothing
%>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>