请教一个asp翻页代码的编写
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><linkrel="stylesheet...
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../Css/Style.css" type="text/css" />
<style type="text/css">
<!--.lSTYLE2 {font-size: 20px;}-->
</style>
</head>
<body>
<%
dim sql,Survey_id
Survey_id=request.QueryString("Survey_id")
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select Survey_name from [Survey] where Survey_id="&Survey_id
rs.open sql,conn,1,1
if rs.eof then
call ShowAlert("参数错误","")
end if
'response.Write(rs("Survey_name"))
%>
<table width="900" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="45" align="center" ><span class="lSTYLE2">【查看:<%=rs("Survey_name")%>的单个问卷】</span></td>
</tr>
</table>
<%
rs.close
Set rs=Nothing
%>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="900" height="20" border="0" align="left" cellpadding="0" cellspacing="1" >
<%
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from [userDatum] where userDatum_belong="&Survey_id
rs.open sql,conn,1,1
%>
<tr align="left">
<td width="180" height="35" align="left" valign="middle" calign="left"> 【<%=rs("userDatum_xuexiao")%>】</td>
<td align="left" height="35" width="180">姓名:【<%=rs("userDatum_name")%>】</td>
<td align="left" height="35" width="100"> 详细内容查看</td>
</tr> </table></td>
</tr> <tr align="right"> <td> <%
rs.close
Set rs=Nothing
%> </td> </tr></table></body></html> 展开
<link rel="stylesheet" href="../Css/Style.css" type="text/css" />
<style type="text/css">
<!--.lSTYLE2 {font-size: 20px;}-->
</style>
</head>
<body>
<%
dim sql,Survey_id
Survey_id=request.QueryString("Survey_id")
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select Survey_name from [Survey] where Survey_id="&Survey_id
rs.open sql,conn,1,1
if rs.eof then
call ShowAlert("参数错误","")
end if
'response.Write(rs("Survey_name"))
%>
<table width="900" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="45" align="center" ><span class="lSTYLE2">【查看:<%=rs("Survey_name")%>的单个问卷】</span></td>
</tr>
</table>
<%
rs.close
Set rs=Nothing
%>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="900" height="20" border="0" align="left" cellpadding="0" cellspacing="1" >
<%
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from [userDatum] where userDatum_belong="&Survey_id
rs.open sql,conn,1,1
%>
<tr align="left">
<td width="180" height="35" align="left" valign="middle" calign="left"> 【<%=rs("userDatum_xuexiao")%>】</td>
<td align="left" height="35" width="180">姓名:【<%=rs("userDatum_name")%>】</td>
<td align="left" height="35" width="100"> 详细内容查看</td>
</tr> </table></td>
</tr> <tr align="right"> <td> <%
rs.close
Set rs=Nothing
%> </td> </tr></table></body></html> 展开
2个回答
展开全部
<%
set rs=server.createobject("adodb.recordset")
sql="select * from [table] order by [ID] DESC"
rs.open sql,conn,1,1
MyPagesize=15 '每页条数
RS.pagesize = MyPagesize
MyRecordCount=rs.recordcount
MyPageCount=rs.pagecount
curpage=cint(request.querystring("page"))
if curpage=0 then curpage=1
RS.absolutepage = curpage
for i=0 to MyPagesize-1
ID=rs("id")
'其他=rs("其他")
RESPONSE.WRITE ID &"<br>"
RESPONSE.WRITE "其他" &"其他<br>"
rs.MoveNext
if RS.eof then
i = i + 1
exit for
End If
next
rs.close
set rs=Nothing
Conn.close
set Conn=Nothing
%>
<table><tr><td>
<% = ExportPageInfo( curpage, i, "page.asp?username="&username&"&") %>
</td></tr></table>
<%
Function ExportPageInfo(curpage,i,LinkFile)
Dim retval, j, pageNumber, BasePage
retval = "第" & curpage & "页/总" & MyPageCount & "页 "
retval = retval & "本页" & i & "条/总" & MyRecordCount & "条 "
If curpage = 1 Then
retval = retval & "首页 前页 "
Else
retval = retval & "<a href='" & LinkFile & "page=1'>首页</a> <a href='" & LinkFile & "page=" & cstr(curpage - 1) & "'>前页
</a> "
End If
If curpage < MyPageCount Then
retval = retval & "<a href='" & LinkFile & "page=" & cstr(curpage+1) & "'>后页</a> <a href='" & LinkFile & "page=" & cstr
(MyPageCount) & "'>末页</a>"
else
retval = retval & "后页 末页"
End if
retval = retval & "<br/>"
ExportPageInfo = retval
End Function
%>
set rs=server.createobject("adodb.recordset")
sql="select * from [table] order by [ID] DESC"
rs.open sql,conn,1,1
MyPagesize=15 '每页条数
RS.pagesize = MyPagesize
MyRecordCount=rs.recordcount
MyPageCount=rs.pagecount
curpage=cint(request.querystring("page"))
if curpage=0 then curpage=1
RS.absolutepage = curpage
for i=0 to MyPagesize-1
ID=rs("id")
'其他=rs("其他")
RESPONSE.WRITE ID &"<br>"
RESPONSE.WRITE "其他" &"其他<br>"
rs.MoveNext
if RS.eof then
i = i + 1
exit for
End If
next
rs.close
set rs=Nothing
Conn.close
set Conn=Nothing
%>
<table><tr><td>
<% = ExportPageInfo( curpage, i, "page.asp?username="&username&"&") %>
</td></tr></table>
<%
Function ExportPageInfo(curpage,i,LinkFile)
Dim retval, j, pageNumber, BasePage
retval = "第" & curpage & "页/总" & MyPageCount & "页 "
retval = retval & "本页" & i & "条/总" & MyRecordCount & "条 "
If curpage = 1 Then
retval = retval & "首页 前页 "
Else
retval = retval & "<a href='" & LinkFile & "page=1'>首页</a> <a href='" & LinkFile & "page=" & cstr(curpage - 1) & "'>前页
</a> "
End If
If curpage < MyPageCount Then
retval = retval & "<a href='" & LinkFile & "page=" & cstr(curpage+1) & "'>后页</a> <a href='" & LinkFile & "page=" & cstr
(MyPageCount) & "'>末页</a>"
else
retval = retval & "后页 末页"
End if
retval = retval & "<br/>"
ExportPageInfo = retval
End Function
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给你段代码加例子 引用时用: <!--#include Virtual="page.inc"--> 语句即可
<%
Sub ShowPageBar(TotalPage,CurPage,strUrl)
' 参数TotalPage:全部页数;CurPage:当前页数;strUrl:翻页使用的连接地址
DIM strPage
CurPage=GetValidPageNO(TotalPage,CurPage) Response.Write "<TABLE WIDTH=''100%''>"
Response.Write "<TR><td width=''100%'' align=''right''>"
Response.Write "页数:" & CurPage & "/" & TotalPage & " " IF InSTR(strUrl,"?")=0 THEN strPage="?Page=" ELSE
strPage="&Page=" END IF
IF Curpage>1 THEN
Response.Write "<a href=" & strUrl &strPage&"1>第一页</a>"
ELSE
Response.Write "第一页"
END IF
IF CurPage>=2 THEN
Response.Write "<a href=" & strUrl & strPage &CurPage-1&">上一页</a>"
ELSE
Response.Write "上一页"
END IF
IF cInt(CurPage)<cInt(TotalPage) THEN
Response.Write "<a href=" & strUrl & strPage &CurPage+1&">下一页</a>"
ELSE
Response.Write "下一页"
END IF
IF cInt(CurPage) <>cInt(TotalPage) THEN
Response.Write "<a href=" & strUrl & strPage & TotalPage&">最末页</a>"
ELSE
Response.Write "最末页"
END IF
Response.Write "</TD></tr></table>"
END SUB
Function GetValidPageNo(PageCount,CurPage)
Dim iPage iPage=CurPage
IF cInt(CurPage)<1 THEN iPage= 1 END IF
IF cInt(iPage) > cInt(PageCount) THEN iPage= PageCount END IF
GetValidPageNo=iPage END Function %>
-----------------------------------------------
看看引用这个函数的例子: chunfeng.asp
<!--#include Virtual="page.inc"--> <%
SET objConn=Server.CreateObject("ADODB.CONNECTION") SET objRst=Server.CreateObject("ADODB.RECORDSET") objConn.Open APPLICATION("dsn")
strSQL="SELECT * FROM 要使用的查询 objRst.Open strSQL,objConn,adOpenStatic ' 打开数据记录 objRst.PageSize=20
' 设置单页的数据记录数 iPageCount=objRst.PageCount
' 定义了一个页码数量的变量
If Len(Request.QueryString("Page"))=0 Then
CurPage=1
Else
CurPage=CInt(Request.Querystring("Page"))
End If
' 得到当前的页码
objRst.AbsolutePage=CurPage ' 设置记录集中的当前页
' 开始调用显示翻页的函数,显示页数栏
' 函数原型:ShowPageBar(TotalPage,CurPage,strUrl) strUrl="chunfeng.asp"
' 定义连接的URL,可以用我们自己的页面地址 ShowPageBar iPageCount,CurPage,strUrl ' 调用完成
---------------------------------------------------------------------------------------------------------------- 这里显示自己的内容
----------------------------------------------------------------------------------------------------------------
objConn.Close
SET objRst=NOTHING SET objConn=NOTHING %>
<%
Sub ShowPageBar(TotalPage,CurPage,strUrl)
' 参数TotalPage:全部页数;CurPage:当前页数;strUrl:翻页使用的连接地址
DIM strPage
CurPage=GetValidPageNO(TotalPage,CurPage) Response.Write "<TABLE WIDTH=''100%''>"
Response.Write "<TR><td width=''100%'' align=''right''>"
Response.Write "页数:" & CurPage & "/" & TotalPage & " " IF InSTR(strUrl,"?")=0 THEN strPage="?Page=" ELSE
strPage="&Page=" END IF
IF Curpage>1 THEN
Response.Write "<a href=" & strUrl &strPage&"1>第一页</a>"
ELSE
Response.Write "第一页"
END IF
IF CurPage>=2 THEN
Response.Write "<a href=" & strUrl & strPage &CurPage-1&">上一页</a>"
ELSE
Response.Write "上一页"
END IF
IF cInt(CurPage)<cInt(TotalPage) THEN
Response.Write "<a href=" & strUrl & strPage &CurPage+1&">下一页</a>"
ELSE
Response.Write "下一页"
END IF
IF cInt(CurPage) <>cInt(TotalPage) THEN
Response.Write "<a href=" & strUrl & strPage & TotalPage&">最末页</a>"
ELSE
Response.Write "最末页"
END IF
Response.Write "</TD></tr></table>"
END SUB
Function GetValidPageNo(PageCount,CurPage)
Dim iPage iPage=CurPage
IF cInt(CurPage)<1 THEN iPage= 1 END IF
IF cInt(iPage) > cInt(PageCount) THEN iPage= PageCount END IF
GetValidPageNo=iPage END Function %>
-----------------------------------------------
看看引用这个函数的例子: chunfeng.asp
<!--#include Virtual="page.inc"--> <%
SET objConn=Server.CreateObject("ADODB.CONNECTION") SET objRst=Server.CreateObject("ADODB.RECORDSET") objConn.Open APPLICATION("dsn")
strSQL="SELECT * FROM 要使用的查询 objRst.Open strSQL,objConn,adOpenStatic ' 打开数据记录 objRst.PageSize=20
' 设置单页的数据记录数 iPageCount=objRst.PageCount
' 定义了一个页码数量的变量
If Len(Request.QueryString("Page"))=0 Then
CurPage=1
Else
CurPage=CInt(Request.Querystring("Page"))
End If
' 得到当前的页码
objRst.AbsolutePage=CurPage ' 设置记录集中的当前页
' 开始调用显示翻页的函数,显示页数栏
' 函数原型:ShowPageBar(TotalPage,CurPage,strUrl) strUrl="chunfeng.asp"
' 定义连接的URL,可以用我们自己的页面地址 ShowPageBar iPageCount,CurPage,strUrl ' 调用完成
---------------------------------------------------------------------------------------------------------------- 这里显示自己的内容
----------------------------------------------------------------------------------------------------------------
objConn.Close
SET objRst=NOTHING SET objConn=NOTHING %>
追问
还是不行的
追答
哪里不行?
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询