① asp分页代码
<%
'如果页数大春凳告于1,则分页显示
self="visit_apply_list.asp"
if page_tot > 1 then
if currentpage > 1 then
response.write"<a href='"&self&"?search=enter&keyselect="&request("keyselect")&"&keyword=粗前"&request("keyword")&"&page=1'>首页</a>-"
response.write"<a href='"&self&"?search=enter&keyselect="&request("keyselect")&"&keyword="&request("keyword")&"&page="¤tpage-1&"'>前页</a>"
else
response.write"首扒明页-</a>"
response.write"前页</a>"
end if
if currentpage < page_tot then
response.write"-<a href='"&self&"?search=enter&keyselect="&request("keyselect")&"&keyword="&request("keyword")&"&page="& currentpage + 1&"'>后页</a>"
response.write"-<a href='"&self&"?search=enter&keyselect="&request("keyselect")&"&keyword="&request("keyword")&"page="& page_tot&"'>尾页</a>"
else
response.write"-后页</a>"
response.write"-尾页</a>"
end if
response.write" 页次:"& currentpage &"/"& page_tot &" 20个记录/页 共"& r_t &"个记录"
response.write" 转到 <input name='page' type='text' size='2' value='"¤tpage&"'>"
response.write" <input type='submit' name='search' value='GO'>"
end if
%>
② 求最简单的asp数据显示和分页代码
这是一个简短的分页显示的例子:
<%language="vbscript"
set conn=server.createobject("adodb.connection")
conn.oen "driver={sql server};server=huang;uid=sa;pwd=;database=test"
<%pgsize=5
page=request.querystring("page")
sql="select * from test where id1=1"
rs.open sql,conn,1
rs.pagesize=pgsize
pgnm=rs.pagecount
if page=""or clng(page)<1 then page=1
if clng(page)>pgnm then page=pgnm
if pgnm>0 then rs.absolutepage=page
count=0
do while not rs.eof and count<pgsize
%><%rs("id1")%><br>
<%=d%><br>
<%count=count+1
rs.movenext
loop
rs.close
set rs=nothing
%>
<a href=dis.asp?page=1>第一页</A>
<A HREF=DIS.ASP?PAGE=<%=PGNM%>>最后一页</A>
<A HREF=DIS.ASP?PAGE=<%=PAGE+1%>>下一页</A>
<A HREF=DIS.ASP?PAGE=<%=PAGE-1%>>上一页</A>
③ asp分页程序代码解释100分送上!
<%
exec="select * from test" //设置查询 TEST 表里面的所有项目
set rs=server.createobject("adodb.recordset") //设置记录集
rs.open exec,conn,1,1 //设置为只读方式执行查询
rs.PageSize=3 //设置分页大小
pagecount=rs.PageCount //读取总的页数
page=int(request.QueryString ("page")) //取得用户点击传过来的页面号
if page<=0 then page=1 //如果传过来的参数小于等于0 则是第一页
if request.QueryString("page")="" then page=1 //如果传过来的参数为空 则是第一页
rs.AbsolutePage=page //指定游磨当前所在页
%>
ASP记录集方法,不一定非神早斗要设置为 rs. 这个可以随意设置的,只要不是保留的变量
rs.movenext 将记录指针从当前的位置向下移一行
rs.moveprevious 将记录指针从当前的位置向上移一行
rs.movefirst 将记录指针移到数据表第一行
rs.movelast 将记录指针移到数据表最后一行
rs.absoluteposition=N 将记录指针移到数据表第N行
rs.absolutepage=N 将记录指针移到第N页的第一行
rs.pagesize=N 设置每页为N条记录
rs.pagecount 根据 pagesize 的设置返回总页数
rs.recordcount 返回记录总数
rs.bof 返回记录指针是否超出数据表首端,true表示是,false为否
rs.eof 返回记录指针是否超出数据表末端,true表示是,false为否
rs.delete 删除当前记录,但记录指针睁判不会向下移动
rs.addnew 添加记录到数据表末端
rs.update 更新数据表记录
④ asp代码分页
Function rsToPageHtml(rsPage,PageSize,rsUrl)
If rsPage.EOF Then
rsToPageHtml = "Nothing yet! Please check back later."
Exit Function
End If
Dim rsCount,PageCount,Page,sScriptName,strTemp
Dim tmpPage, intPage, allPage
rsCount = rsPage.RecordCount
rsPage.PageSize = PageSize
PageCount = rsPage.PageCount
Page = Request("Page")
if Page="" then
Page = 1
else
Page = Clng(Page)
end if
if Page < 1 then Page = 1
If Page > Pagecount Then Page = Pagecount
rsPage.AbsolutePage = Page
'sScriptName = Request.ServerVariables("SCRIPT_NAME")
if InstrRev(rsUrl,".asp?") > 0 then
rsUrl = rsUrl & "&Page="
else
rsUrl = rsUrl & "?Page="
end if
strTemp = ""
tmpPage = 10
intPage = Int((Page-1) / tmpPage)
allPage = Int(Pagecount / tmpPage)
If Page<>1 and intPage<>0 Then strTemp = strTemp &"<a href="裤旁""& rsUrl &"1"" title=首页><font face=webdings>9</font></a> "
If intPage>0 Then strTemp = strTemp &"<a href="""& rsUrl & ((intPage-1)*tmpPage+1) &""" title=前十页><font face=webdings>7</font></a> "
if page>1 then strTemp = strTemp &"<a href="""& rsUrl & page-1 &""" title=""上一页""><font face=""webdings"">3</font></a> "
If intPage<allPage Then
For n=(intPage*tmpPage+1) To (intPage+1)*tmpPage
If n=Page Then
strTemp = strTemp &" <font color=red><b>"& n &"</b></font> "
Else
strTemp = strTemp &" <a href="""& rsUrl & n &"""><b>"& n &"</b></a> "
End If
Next
Else
For n=(intPage*tmpPage+1) To Pagecount
If n=Page Then
strTemp = strTemp &" <font color=red><b>"& n &"</b></font> "
Else
strTemp = strTemp &" <a href="""& rsUrl & n &"""><b>"& n &"</b></a> "
End If
Next
End If
if page<PageCount then strTemp = strTemp &"<a href="""& rsUrl & page+1 &""" title=""下一页""><font face=""webdings"">4</font></a> "
If intPage<allPage Then strTemp = strTemp &"<a href="""& rsUrl & ((intPage+1)*tmpPage+1) &""" title=后十页><font face=webdings> </腊高font></a> "
If Page<>Pagecount and intPage<>allPage Then strTemp = strTemp &"<a href="""& rsUrl & Pagecount &""" title=末页><font face=webdings>:</font></a> "
strTemp = strTemp &" "& PageCount &轮纯尺" pages "&" "&rsCount&" pics"
rsToPageHtml = strTemp
End Function
function ifspace(Name)
if Name<>"" then
ifspace=Name
else
ifspace="-"
end if
end function
⑤ asp分页代码
<%
function page(a,RCount,PCount,P,unl)'--------------分页函数
if a=1 then
if p=1 then
show= "<input type=""submit"" name=""p1"" value=""首页"" disabled >"
else
show= "<input type=""submit"" name=""p1"" value=""首页"" onClick=""location.href='"&unl&"1';"" >"
end if
if p>1 then
show=show+" <input type=""submit"" name=""p2"" value=""上一页"" onClick=""location.href='"&unl&p-1&"';"">"
else
show=show+" <input type=""submit"" name=""p2"" value=""上一页"" disabled >"
end if
if p<PCount then
show=show+" <input type=""submit"" name=""p3"" value=""下一页"" onClick=""location.href='"&unl&p+1&"';"">"逗升
else
show=show+" <input type=""submit"" name=""p3"" value=""下一页"" disabled >"
end if
if p>=PCount then
show=show+" <input type=""submit"" name=""p4"" value=""末页"" disabled>"
else
show=show+" <input type=""submit"" name=""p4"" value=""末页"" onClick=""location.href='"&unl&PCount&"';"">"
end if
show=show+" 当前页"&P&"/"&PCount&" 记录总数"&RCount
end if
if a=2 then
show="<span class=""text"">"
show=show+"共有"&rcount&"个记录"
if p=1 then
show=show+" | 首页 "
else
show=show+" | <a href='"&unl&"1' class='text'>首页</a> "
end if
if p>1 then
show=show+"| <a href='"&unl&p-1&"' class='text'>上一页</a> "
else
show=show+"| 上一页 "
end if
if p<pcount then
show=show+"| <a href='"&unl&p+1&"' class='text'>下一页</a> "
else
show=show+"| 下一页 "
end if
if p>=pcount then
show=show+"| 尾页 "
else
show=show+"| <a href='"&unl&pcount&"' class='text'>尾页</a> "
end if
show=show+"| 页次:"&p&"/"&pcount&"页 | 共"&pcount&"页"
show=show+"</span>"
end if
if a=3 then
show="<span class=""text"">"
BlockPage=Int((P-1)/10)*10+1
IF BlockPage = 1 Then
show=show+ "<<"
else
show=show+ "<a href="&unl&BlockPage-1&" class=""text""><<</a>"
end if
i=1
Do Until i > 10 OR BlockPage > PCount
IF BlockPage=int(P) Then
show=show+ "<font color=red> "&BlockPage&带明"</font>"
else
show=show+ "<a href="&unl&BlockPage&" class=""text""> "&BlockPage&"</a>"
end if
BlockPage=BlockPage+1
i = i + 1
Loop
if pcount>10 then
show=show+ "...<a href="&unl&pcount&" class=""text"">"&pcount&"</a>"
end if
if BlockPage>pcount then
show=show+ "蠢指告>> "
else
show=show+ "<a href="&unl&BlockPage&" class=""text"">>> </a>"
end if
show=show+"</span>"
end if
response.write show
end function
%>
⑥ 做一个简单的ASP分页程序
本程序主要用到Connection、RecordSet这两个对象,程序中的数据库为Access库,采用OLEDB方式连接库。
这个东西是作为菜鸟的我弄的一个东西.
你可以对这个东西不屑一顾.但是请记住: 菜鸟源喊衡也有这个权利把自己的心得体会附注文字贡献出来.....当然,技术方面渗吵真的是好菜的..一些ASP中的比较正统的中规中矩的方法.我觉得这个东西可能对初学者有些帮助.......见笑了..
一个简单的分页教程:
<%
Setconn=Server.CreateObject("ADODB.Connection")
strcon="provider=microsoft.jet.oledb.4.0;datasource="&_
server.mappath("mdb.mdb")
conn.Openstrcon
Setrs=Server.CreateObject("ADODB.Recordset")
sql="select*fromtableorderbyiddesc"
rs.Opensql,conn,1
page=1'设置变量PAGE=1
rs.PageSize=5'每页显示记录数
ifNotIsEmpty(Request("Page"))then'如果PAGE已经初始化...
Page=CInt(Request("Page"))'接收PAGE并化为数字型赋给PAGE变量
ifPage>rs.PageCountthen'如果接收的页数大于总页数
rs.AbsolutePage=rs.PageCount'设置当前显示页等于最后页
elseifPage<=0then'如果page小于等于0
Page=1'设置PAGE等于第一页
else
rs.AbsolutePage=Page'如果大于零,显示当前页等于接收的页数
endif
Endif
Page=rs.AbsolutePage
%>
<%
Fori=1tors.PageSize
ifrs.EOFthen
ExitFor
endif'利用fornext循环雹做依次读出记录
%>