我想创建一个有PREV和NEXT按钮的页面。当我按下NEXT按钮时,数据库中的下一个信息 样品:
ID Firstname Lastname Gender Position
112 Victor bbb Male Programmer
232 Anna xxxx Female Manager
301 yyyy yyyy male Clerk
此数据连接到其他表
示例输出htm视图
ID : 112
Fullname: victor bbb Gender : Male
Position: Programmer Department: xxx
other information: blahblah
-------------------------------------------
<-PREV- -NEXT-->
当我点击下一个按钮时,会出现anna的信息。 怎么能在asp中实现呢?我是asp的新手,所以我现在不知道怎么做。
答案 0 :(得分:0)
//retrieve requested page
page = request.querystring("page")
MyPageSize=10
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adUseClient = 3
Const adCmdText = 1
//Make sure the requested page is valid
If page = "" Then
page = 1
else
page = cint(page)
End If
DisplayNum = 0
rs.PageSize = MyPageSize
rs.CursorLocation = adUseClient
SQL="select * from tableName order by id"
rs.Open SQL,objcon
ipage = rs.PageCount
if page = 0 or page > ipage Then
rs.AbsolutePage = ipage
else
rs.AbsolutePage = page
end if
Do While Not rs.EOF AND DisplayNum < MyPageSize
//Main Code to display data goes here for example resonse.write rs("id")&"<br>"
DisplayNum = DisplayNum + 1
rs.MoveNext
Loop
//Display navigation if pages are more than 1
If ipage > 1 Then
if ipage > 1 And page > 1 Then
response.write "<a href='?page="&page-1&"'>"&page-1&"</a> "
end if
For z = 1 to ipage
If z = page then
response.write page
Else
response.write "<a href='?page="&z&"'>"&z&"</a> "
End If
Next
If ipage > 1 And page < ipage Then
response.write "<a href='?page="&page+1&"'>"&page+1&"</a>"
end if
end if
rs.Close