[ASP]谁可以帮我这代码改成分页的?
如题,代码如下:<%subarticle_listdimcIDcID=Request.QueryString("id")dimJDID,JDName,JDWriter,J...
如题,代码如下:
<%
sub article_list
dim cID
cID=Request.QueryString("id")
dim JDID,JDName,JDWriter,JDTime,JDTime_s,JDHit
sql="select id,title,writer,writedate,hit from article where aclass='"&cID&"' order by id desc"
set rs=conn.execute(sql)
if rs.eof and rs.bof then
response.write "<li class='biaoti'>等待添加。。。</li>"
else
do while not rs.eof
JDID=rs(0)
JDName=rs(1)
JDWriter=rs(2)
JDTime=rs(3)
JDTime_s=Year(rs(3))& "-" &Month(rs(3))& "-" &Day(rs(3))
JDHit=rs(4)
%>
<li class="biaoti"><a href="article_show.asp?id=<%=JDID%>" title="作者:<%=JDWriter%>"><%=JDName%></a> (<%=JDTime_s%>) <font color=#FF0000>点击:<%=JDHit%></font></li>
<%
rs.movenext
loop
end if
end sub
%>
帮我改成可以分页的。。代码无错的。。 展开
<%
sub article_list
dim cID
cID=Request.QueryString("id")
dim JDID,JDName,JDWriter,JDTime,JDTime_s,JDHit
sql="select id,title,writer,writedate,hit from article where aclass='"&cID&"' order by id desc"
set rs=conn.execute(sql)
if rs.eof and rs.bof then
response.write "<li class='biaoti'>等待添加。。。</li>"
else
do while not rs.eof
JDID=rs(0)
JDName=rs(1)
JDWriter=rs(2)
JDTime=rs(3)
JDTime_s=Year(rs(3))& "-" &Month(rs(3))& "-" &Day(rs(3))
JDHit=rs(4)
%>
<li class="biaoti"><a href="article_show.asp?id=<%=JDID%>" title="作者:<%=JDWriter%>"><%=JDName%></a> (<%=JDTime_s%>) <font color=#FF0000>点击:<%=JDHit%></font></li>
<%
rs.movenext
loop
end if
end sub
%>
帮我改成可以分页的。。代码无错的。。 展开
2个回答
展开全部
<%
dim cID
cID=Request.QueryString("id")
dim JDID,JDName,JDWriter,JDTime,JDTime_s,JDHit
sql="select id,title,writer,writedate,hit from article where aclass='"&cID&"' order by id desc"
set rs=conn.execute(sql)
if rs.eof and rs.bof then
response.write "<li class='biaoti'>等待添加。。。</li>"
else
%>
用表格请在这里加表头
<%
Page=Int(Abs(Request("page")))
IF not IsNumeric(Request("page")) Or IsEmpty(Request("page")) Then page=1
rs.pagesize = 10 '每页显示记录数
total = rs.RecordCount
mp = rs.pagesize
rs.absolutepage = page
i=0:k=0
do while not rs.eof and mp>0:k=k+1
JDID=rs(0)
JDName=rs(1)
JDWriter=rs(2)
JDTime=rs(3)
JDTime_s=Year(rs(3))& "-" &Month(rs(3))& "-" &Day(rs(3))
JDHit=rs(4)
%>
<li class="biaoti"><a href="article_show.asp?id=<%=JDID%>" title="作者:<%=JDWriter%>"><%=JDName%></a> (<%=JDTime_s%>) <font color=#FF0000>点击:<%=JDHit%></font></li>
<BR>
<%
i=i+1
mp=mp-1
rs.movenext
loop
if page>rs.pagecount then Response.redirect("?page="&rs.pagecount)
if page>1 then
response.Write(" <br><p><a href='?&page=1' title='首页'>首页</a>")
response.Write(" <a href='?page="&page-1&"' title='上一页'>上一页</a>")
end if
response.Write("<br><p>第"&page&"/"&rs.pagecount&"页 共"&total&"条记录 本页显示第"&(page-1)*rs.pagesize+1&"条到第"&(page-1)*rs.pagesize+k&"条 ")
if page<rs.pagecount then
response.Write(" <a href='?page="&page+1&"' title='下一页'>下一页</a>")
response.Write(" <a href='?page="&rs.pagecount&"' title='尾页'>尾页</a>")
end if
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
dim cID
cID=Request.QueryString("id")
dim JDID,JDName,JDWriter,JDTime,JDTime_s,JDHit
sql="select id,title,writer,writedate,hit from article where aclass='"&cID&"' order by id desc"
set rs=conn.execute(sql)
if rs.eof and rs.bof then
response.write "<li class='biaoti'>等待添加。。。</li>"
else
%>
用表格请在这里加表头
<%
Page=Int(Abs(Request("page")))
IF not IsNumeric(Request("page")) Or IsEmpty(Request("page")) Then page=1
rs.pagesize = 10 '每页显示记录数
total = rs.RecordCount
mp = rs.pagesize
rs.absolutepage = page
i=0:k=0
do while not rs.eof and mp>0:k=k+1
JDID=rs(0)
JDName=rs(1)
JDWriter=rs(2)
JDTime=rs(3)
JDTime_s=Year(rs(3))& "-" &Month(rs(3))& "-" &Day(rs(3))
JDHit=rs(4)
%>
<li class="biaoti"><a href="article_show.asp?id=<%=JDID%>" title="作者:<%=JDWriter%>"><%=JDName%></a> (<%=JDTime_s%>) <font color=#FF0000>点击:<%=JDHit%></font></li>
<BR>
<%
i=i+1
mp=mp-1
rs.movenext
loop
if page>rs.pagecount then Response.redirect("?page="&rs.pagecount)
if page>1 then
response.Write(" <br><p><a href='?&page=1' title='首页'>首页</a>")
response.Write(" <a href='?page="&page-1&"' title='上一页'>上一页</a>")
end if
response.Write("<br><p>第"&page&"/"&rs.pagecount&"页 共"&total&"条记录 本页显示第"&(page-1)*rs.pagesize+1&"条到第"&(page-1)*rs.pagesize+k&"条 ")
if page<rs.pagecount then
response.Write(" <a href='?page="&page+1&"' title='下一页'>下一页</a>")
response.Write(" <a href='?page="&rs.pagecount&"' title='尾页'>尾页</a>")
end if
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
展开全部
最简单的asp分页
<%
set conn=server.createobject("adodb.connection")
conn.open("DRIVER=Driver do Microsoft Access (*.mdb);UID=admin;pwd=;dbq="&server.mappath("1.mdb"))
set rs=server.createobject("adodb.recordset")
sql="select * from student"
rs.open sql,conn,3
rs.pagesize=20
if request("page")<>"" then
epage=cint(request("page"))
if epage<1 then epage=1
if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage
%>
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#0000FF" width="80%" align="center">
<tr bgcolor="#FFFFFF" align="center">
<th><%=rs(0).name%></th><th><%=rs(1).name%></th><th><%=rs(2).name%></th>
</tr>
<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>
<tr bgcolor="#FFFFFF" align="center">
<td><%=rs(0).value%></td><td><%=rs(1).value%></td><td><%=rs(2).value%></td>
</tr>
<%
rs.movenext()
next
%>
</table>
<p align="center">
<a href="">首页</a>
<a href="index.asp?page=<%=epage-1%>">前一页</a>
<a href="index.asp?page=<%=epage+1%>">后一页</a>
<a href="index.asp?page=<%=rs.pagecount%>">末页</a>
</p>
<p align="center">现在是第<%=epage%>页一共有<%=rs.pagecount%>页</p>
<%
conn.close()
%>
<%
set conn=server.createobject("adodb.connection")
conn.open("DRIVER=Driver do Microsoft Access (*.mdb);UID=admin;pwd=;dbq="&server.mappath("1.mdb"))
set rs=server.createobject("adodb.recordset")
sql="select * from student"
rs.open sql,conn,3
rs.pagesize=20
if request("page")<>"" then
epage=cint(request("page"))
if epage<1 then epage=1
if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage
%>
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#0000FF" width="80%" align="center">
<tr bgcolor="#FFFFFF" align="center">
<th><%=rs(0).name%></th><th><%=rs(1).name%></th><th><%=rs(2).name%></th>
</tr>
<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>
<tr bgcolor="#FFFFFF" align="center">
<td><%=rs(0).value%></td><td><%=rs(1).value%></td><td><%=rs(2).value%></td>
</tr>
<%
rs.movenext()
next
%>
</table>
<p align="center">
<a href="">首页</a>
<a href="index.asp?page=<%=epage-1%>">前一页</a>
<a href="index.asp?page=<%=epage+1%>">后一页</a>
<a href="index.asp?page=<%=rs.pagecount%>">末页</a>
</p>
<p align="center">现在是第<%=epage%>页一共有<%=rs.pagecount%>页</p>
<%
conn.close()
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询