ASP 如何让循环显示达到分页效果?
以下是全部文件代码,请帮忙做成没10条为一页的分页<%@LANGUAGE="VBScript"codepage="936"%><%ifsession("admin")<>...
以下是全部文件代码,请帮忙做成没10条为一页的分页
<%@LANGUAGE="VBScript" codepage="936"%>
<%if session("admin")<>"" then%>
<!--#include file="conn.asp"-->
<%
set rs=server.createobject("adodb.recordset")
sql="select id,titledata,httpdata,email,bodydata,data from so order by id desc"
rs.open sql,conn,1,1
%>
<%do while not rs.eof%>
<html>
<head>
<title>首页</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><TABLE id=Table40 cellSpacing=1 cellPadding=3 width=100%
bgColor=#999999 border=0>
<TBODY>
<TR>
<TD colspan="2" bgColor=#EAEAEA><TABLE width="100%"
border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD height="21"><P style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><font color="#2319DC">标题: <%=rs("titledata")%></font></P></TD>
<TD width="182">提交时间:<%=rs("data")%></TD>
<TD width="150" align=right><a href="<%=rs("httpdata")%>" target="_blank"><font color="#009900">链接</font></a> <a href="mailto:<%=rs("email")%>"><font color="#999999">邮件</font></a> <a href="del.asp?id=<%=rs("id")%>" onclick="return confirm('是否确定删除本留言?');"><font color="#FF0000">删除</font></a> <a href="logout.asp"><font color="#0000FF">退出</font></a></TD>
</TR>
</TBODY>
</TABLE></TD>
</TR>
<TR>
<TD width=78 bgColor=white><P class="text2" style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><font color="#FF0000">简介:</font></p></TD>
<TD width="843" bgColor=white><P style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><%=rs("bodydata")%></p></TD>
</TR>
</TBODY>
</TABLE></td>
</tr>
<tr>
<td height="25"></td>
</tr>
</table>
<%
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</body>
</html>
<%
else
response.Redirect("admin.asp")
end if%>
您修改的代码出现以下错误
错误类型:
Microsoft VBScript 编译器错误 (0x800A040E)
'loop' 语句缺少 'do'
/admin/index.asp, line 68
Loop 展开
<%@LANGUAGE="VBScript" codepage="936"%>
<%if session("admin")<>"" then%>
<!--#include file="conn.asp"-->
<%
set rs=server.createobject("adodb.recordset")
sql="select id,titledata,httpdata,email,bodydata,data from so order by id desc"
rs.open sql,conn,1,1
%>
<%do while not rs.eof%>
<html>
<head>
<title>首页</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><TABLE id=Table40 cellSpacing=1 cellPadding=3 width=100%
bgColor=#999999 border=0>
<TBODY>
<TR>
<TD colspan="2" bgColor=#EAEAEA><TABLE width="100%"
border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD height="21"><P style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><font color="#2319DC">标题: <%=rs("titledata")%></font></P></TD>
<TD width="182">提交时间:<%=rs("data")%></TD>
<TD width="150" align=right><a href="<%=rs("httpdata")%>" target="_blank"><font color="#009900">链接</font></a> <a href="mailto:<%=rs("email")%>"><font color="#999999">邮件</font></a> <a href="del.asp?id=<%=rs("id")%>" onclick="return confirm('是否确定删除本留言?');"><font color="#FF0000">删除</font></a> <a href="logout.asp"><font color="#0000FF">退出</font></a></TD>
</TR>
</TBODY>
</TABLE></TD>
</TR>
<TR>
<TD width=78 bgColor=white><P class="text2" style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><font color="#FF0000">简介:</font></p></TD>
<TD width="843" bgColor=white><P style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><%=rs("bodydata")%></p></TD>
</TR>
</TBODY>
</TABLE></td>
</tr>
<tr>
<td height="25"></td>
</tr>
</table>
<%
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</body>
</html>
<%
else
response.Redirect("admin.asp")
end if%>
您修改的代码出现以下错误
错误类型:
Microsoft VBScript 编译器错误 (0x800A040E)
'loop' 语句缺少 'do'
/admin/index.asp, line 68
Loop 展开
展开全部
糊涂了 糊涂了 因为我现在在网吧,这里没有dw 更没有iis
刚才我又调试了一下,如果出现轻微的错误,再调试
分这么少啊?只不过还是帮你一把
你这篇文章代码修改为
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%if session("admin")<>"" then%>
<!--#Include file="conn.asp"-->
<!--#Include file="function.asp"-->
<% Dim sql,rs
set rs=server.createobject("adodb.recordset")
sql="select id,titledata,httpdata,email,bodydata,data from so order by id desc"
rs.Open sql,conn,1
%>
num=rs.recordcount
If Not rs.Bof And Not rs.Eof Then
Dim page_size
Dim page_no
Dim page_total
page_size=10
If Request("page_no")="" Then
page_no=1
Else
page_no=cint(Request("page_no"))
End If
Session("page_no")=page_no
rs.PageSize=page_size
page_total=rs.PageCount
rs.AbsolutePage=page_no
Dim I,J
I=0
J=page_size %>
<html>
<head>
<title>首页</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><TABLE id=Table40 cellSpacing=1 cellPadding=3 width=100%
bgColor=#999999 border=0>
<TBODY>
<TR>
<TD colspan="2" bgColor=#EAEAEA><TABLE width="100%"
border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD height="21"><P style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><font color="#2319DC">标题: <%=rs("titledata")%></font></P></TD>
<TD width="182">提交时间:<%=rs("data")%></TD>
<TD width="150" align=right><a href="<%=rs("httpdata")%>" target="_blank"><font color="#009900">链接</font></a> <a href="mailto:<%=rs("email")%>"><font color="#999999">邮件</font></a> <a href="del.asp?id=<%=rs("id")%>" onclick="return confirm('是否确定删除本留言?');"><font color="#FF0000">删除</font></a> <a href="logout.asp"><font color="#0000FF">退出</font></a></TD>
</TR>
</TBODY>
</TABLE></TD>
</TR>
<TR>
<TD width=78 bgColor=white><P class="text2" style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><font color="#FF0000">简介:</font></p></TD>
<TD width="843" bgColor=white><P style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><%=rs("bodydata")%></p></TD>
</TR>
</TBODY>
</TABLE></td>
</tr>
<%
Do While Not rs.Eof And J>0
I=I+1
J=J-1
%>
<tr>
<td height="25"></td>
</tr>
</table>
<%
rs.MoveNext
Loop
End If
%>
</body>
</html>
<%
else
response.Redirect("admin.asp")
end if%>
然后在添加一个调用页码的asp文件 function.asp 代码为
<%
private sub select_page(page_no,total_page)
'该子程序依次写出各页页码,并将非当前页设置超链接,当前页则不设置
Response.Write "请选择页码:"
Dim I
for I=1 to total_page
If I=page_no Then
Response.Write I & " "
Else
Response.Write "<a href='index.asp?page_no=" & I & "'>" & I & "</a> "
End If
next
End sub
%>
你本身的页面是什么就把 index.asp改为什么
刚才我又调试了一下,如果出现轻微的错误,再调试
分这么少啊?只不过还是帮你一把
你这篇文章代码修改为
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%if session("admin")<>"" then%>
<!--#Include file="conn.asp"-->
<!--#Include file="function.asp"-->
<% Dim sql,rs
set rs=server.createobject("adodb.recordset")
sql="select id,titledata,httpdata,email,bodydata,data from so order by id desc"
rs.Open sql,conn,1
%>
num=rs.recordcount
If Not rs.Bof And Not rs.Eof Then
Dim page_size
Dim page_no
Dim page_total
page_size=10
If Request("page_no")="" Then
page_no=1
Else
page_no=cint(Request("page_no"))
End If
Session("page_no")=page_no
rs.PageSize=page_size
page_total=rs.PageCount
rs.AbsolutePage=page_no
Dim I,J
I=0
J=page_size %>
<html>
<head>
<title>首页</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><TABLE id=Table40 cellSpacing=1 cellPadding=3 width=100%
bgColor=#999999 border=0>
<TBODY>
<TR>
<TD colspan="2" bgColor=#EAEAEA><TABLE width="100%"
border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD height="21"><P style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><font color="#2319DC">标题: <%=rs("titledata")%></font></P></TD>
<TD width="182">提交时间:<%=rs("data")%></TD>
<TD width="150" align=right><a href="<%=rs("httpdata")%>" target="_blank"><font color="#009900">链接</font></a> <a href="mailto:<%=rs("email")%>"><font color="#999999">邮件</font></a> <a href="del.asp?id=<%=rs("id")%>" onclick="return confirm('是否确定删除本留言?');"><font color="#FF0000">删除</font></a> <a href="logout.asp"><font color="#0000FF">退出</font></a></TD>
</TR>
</TBODY>
</TABLE></TD>
</TR>
<TR>
<TD width=78 bgColor=white><P class="text2" style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><font color="#FF0000">简介:</font></p></TD>
<TD width="843" bgColor=white><P style="MARGIN-TOP: 3px; MARGIN-LEFT: 10px"><%=rs("bodydata")%></p></TD>
</TR>
</TBODY>
</TABLE></td>
</tr>
<%
Do While Not rs.Eof And J>0
I=I+1
J=J-1
%>
<tr>
<td height="25"></td>
</tr>
</table>
<%
rs.MoveNext
Loop
End If
%>
</body>
</html>
<%
else
response.Redirect("admin.asp")
end if%>
然后在添加一个调用页码的asp文件 function.asp 代码为
<%
private sub select_page(page_no,total_page)
'该子程序依次写出各页页码,并将非当前页设置超链接,当前页则不设置
Response.Write "请选择页码:"
Dim I
for I=1 to total_page
If I=page_no Then
Response.Write I & " "
Else
Response.Write "<a href='index.asp?page_no=" & I & "'>" & I & "</a> "
End If
next
End sub
%>
你本身的页面是什么就把 index.asp改为什么
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询