帕拉丁报价和图片:ASP编程实现按字数翻页

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 02:40:37
最近在学习ASP制作个人网页,遇到一个难提,就是在翻页过程中怎么样控制字数翻页。
我在网上找了个程序,却怎么也看不懂,希望高手能给出注释。谢谢!
<%
dim i,intPage,page,pre,last,filepath
set rs = server.CreateObject("adodb.recordset")
if request("id")="" then
mysql="select * from video order by id desc"
else
mysql="select * from video where subclass="& request("id") &" order by id desc"
end if
rs.PageSize =10
rs.CursorLocation = 3
rs.Open mysql,conn,0,2,1 //(这里执行你查询SQL并获得结果记录集
pre = true
last = true
page = trim(Request.QueryString("page"))
if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%>
<!--循环开始-->
<%
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then exit for
%>

<!--内容-->

<%
rs.movenext
next
%>

</table>
<!--循环体结束
分页部分:-->
<table width="99%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
<tr>
<%if rs.pagecount > 0 then%>
<td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
<%else%>
<td width="25%" align="left">当前页0/0</td><%end if%>
<td width="62%" align="right"> <a href="页面.asp?page=1">首页</a>|
<%if pre then%>
<a href="页面.asp?page=<%=intpage -1%>">上页</a>| <%end if%>
<%if last then%>
<a href="页面.asp?page=<%=intpage +1%>">下页</a> |<%end if%>
<a href="页面.asp?page=<%=rs.PageCount%>">尾页</a>|转到第
<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to rs.PageCount
if i = intpage then%>
<option value="/blog/页面.asp?page=<%=i%>" selected><%=i%></option>
<%else%>
<option value="/blog/页面.asp?page=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>页</font>
那能不能按TABLE规定翻页呢?也就是说在规定了TABLE的高度,当文章超过这个高度就翻页到下页!

1、你找的是分页程序,是列表的分页
想实现字数分页很难,尤其是在你的文本里面有图片表格等html代码的时候
你可以提供一下你的页面,具体分析一下再考虑使用那种方法好

我前段时间对一个fso生成html的后台做过分页,我的思路很简单,就是在内容里面插入一个特殊符号作为标志,当读取的时候把内容转换成数组,然后让他在不同页面显示

2、识别一下具体是哪一页就可以了。

你找的是分页程序,是列表的分页
想实现字数分页很难,尤其是在你的文本里面有图片表格等html代码的时候
你可以提供一下你的页面,具体分析一下再考虑使用那种方法好

我前段时间对一个fso生成html的后台做过分页,我的思路很简单,就是在内容里面插入一个特殊符号作为标志,当读取的时候把内容转换成数组,然后让他在不同页面显示

我给你一个显示新闻的吧!
只要看懂了,显示其它的数据也可以依样画葫芦了!
<%
sub showNews(sql,rows,cols,ipage,isShowBookMark,autoLen)
dim rs,page_size,icol,path
if cols="" or not isNumeric(cols) then cols = 1
if cols<=0 then cols = 1
if rows="" or not isNumeric(rows) then rows = 1
if rows<=0 then rows=1
if ipage="" or not isNumeric(ipage) then ipage=1
if ipage<=0 then ipage=1
if autoLen="" or not isNumeric(autoLen) then autoLen = 20
if autoLen<=0 then autoLen = 20

page_size = cols * rows
set rs = server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1
response.write "<table width=100% border=0 cellpadding=0 cellspacing=0 id=news>" & VBCRLF
if rs.eof or rs.bof then
response.write "<tr><td width=100% height=50 align=center valign=middle style='color:red'>暂时没有信息!</tr>" & VBCRLF
response.write "</table>" & VBCRLF
exit sub
end if
rs.pageSize = page_size
if int(ipage) > int(rs.pageCount) then ipage = rs.pageCount
rs.absolutePage = ipage

icol = 0
while not rs.eof and int(icol)<int(page_size)
if icol mod cols = 0 then
response.write "<tr>" & VBCRLF
end if
response.write "<td width=" & int(100/cols) & "% height=20 align=left valign=middle>" & VBCRLF
%>  ·<a href="readData.asp?id=<%=rs("id")%>&DataType=10001" target="_self"><%=autoCut(rs("title"),autoLen)%></a> <span id="time">[<%=DateValue(rs("post_time"))%>](已阅<%=rs("click_count")%>次)</span>
<%
response.write "</td>" & VBCRLF
icol = icol + 1
if icol mod cols = 0 then
response.write "</tr>" & VBCRLF
end if
rs.movenext
wend
if icol mod cols <> 0 then
response.write "<td colspan=" & int(cols - icol mod cols) & "> </td></tr>" & VBCRLF
end if
response.write "</table>"

if isShowBookMark=1 then

dim reg
set reg = new RegExp
reg.pattern = "[&]*page=[0-9]*"
reg.Global = true
reg.Ignorecase = true
path = reg.replace(request.QueryString,"")
if path="" then
path = "?" & path
else
path = "?" & path & "&"
end if
set reg = nothing

response.Write "<br><div style='font-size:12px;color:black'>" & VBCRLF
response.write "<br>总记录数<span style='color:red'>"&rs.recordCount&"</span>   每页<span style='color:red'>" & page_size & "</span>  "
if ipage <= 1 then
response.write "<span style='color:darkgray'>首页 前页</span>"
else
response.write "<a href=" & path & "page=1>首页</a> <a href=" & path & "page="&ipage-1&">前页</a>"
end if
if int(ipage) = int(rs.pageCount) then
response.write "<span style='color:darkgray'> 下页 末页</span>"
else
response.write " <a href=" & path & "page="&ipage+1&">下页</a> <a href=" & path & "page="&rs.pageCount&">末页</a>"
end if
response.write "    第"&ipage&"页 共"&rs.pageCount&"页"
response.write "</div>"

end if
end sub
%>