3个回答
2013-12-06
展开全部
<%
function word_pagination(table,content,wordcount)
dim wordPage,action,ami_wordCount,ami_wordSum,ami_wordMod,ami_pageCount,query, ami, ly, temp
wordPage=request.QueryString("wordPage") '获得wordPage
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
'获得网页地址
query = Split(Request.ServerVariables("QUERY_STRING"), "&") '获得参数,并分解参数
For Each ly In query
ami = Split(ly, "=")'对参数进行分析
If StrComp(ami(0), "wordPage",vbTextCompare) <> 0 Then '若参数排除本函数生成的参数
temp = temp & ami(0) & "=" & ami(1) & "&" '生成参数列表(ami=1)
End If
next
set rs=server.CreateObject("adodb.recordset")
sql="select * from "&table&" " 'table 表明
rs.open sql,conn,1,1
ami_content=rs(""&content&"") 'content 进行分页内容的字段名
ami_wordCount=wordCount '每页字数
ami_wordSum=len(ami_content) '计算总字数
ami_wordMod=ami_wordSum mod ami_wordCount '计算最后一页字数
ami_pageCount=int(ami_wordSum/ami_wordCount)'计算页数,总页数=ami_pagecount+1
if wordPage="all" then '单页显示值
wordPage=0
end if
if isEmpty(wordPage)=true then '分析如wordPage无参数传来,wordpage则为首页
wordPage=1
else
wordPage=int(wordPage) '否则等于参数值,并int
end if
if wordPage=0 then '判断参数的几种类型,并根据参数的类型进行分页
ami_content=ami_content
elseif wordPage<ami_pageCount+1 and wordPage>0 then
ami_content=mid(ami_content,ami_wordCount*(wordPage-1)+1,ami_wordCount)
elseif wordPage=ami_pageCount+1 then
ami_content=mid(ami_content,ami_wordCount*ami_pageCount+1,ami_wordMod)
elseif wordPage>ami_pageCount+1 and wordPage<0 then
ami_content="非法参数,请返回"
end if
response.Write ami_content
response.Write "<br>"
for i=1 to ami_pageCount+1 '页数展示
response.Write "[<a href="&action&"?"&temp&"wordPage="&i&">"&i&"</a>]"
next
response.Write "[<a href="&action&"?"&temp&"wordPage=all>单页显示</a>]"
rs.close
set rs=nothing
end function
调用函数的代码是 <%call word_pagination("amily","content",600)%>
function word_pagination(table,content,wordcount)
dim wordPage,action,ami_wordCount,ami_wordSum,ami_wordMod,ami_pageCount,query, ami, ly, temp
wordPage=request.QueryString("wordPage") '获得wordPage
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
'获得网页地址
query = Split(Request.ServerVariables("QUERY_STRING"), "&") '获得参数,并分解参数
For Each ly In query
ami = Split(ly, "=")'对参数进行分析
If StrComp(ami(0), "wordPage",vbTextCompare) <> 0 Then '若参数排除本函数生成的参数
temp = temp & ami(0) & "=" & ami(1) & "&" '生成参数列表(ami=1)
End If
next
set rs=server.CreateObject("adodb.recordset")
sql="select * from "&table&" " 'table 表明
rs.open sql,conn,1,1
ami_content=rs(""&content&"") 'content 进行分页内容的字段名
ami_wordCount=wordCount '每页字数
ami_wordSum=len(ami_content) '计算总字数
ami_wordMod=ami_wordSum mod ami_wordCount '计算最后一页字数
ami_pageCount=int(ami_wordSum/ami_wordCount)'计算页数,总页数=ami_pagecount+1
if wordPage="all" then '单页显示值
wordPage=0
end if
if isEmpty(wordPage)=true then '分析如wordPage无参数传来,wordpage则为首页
wordPage=1
else
wordPage=int(wordPage) '否则等于参数值,并int
end if
if wordPage=0 then '判断参数的几种类型,并根据参数的类型进行分页
ami_content=ami_content
elseif wordPage<ami_pageCount+1 and wordPage>0 then
ami_content=mid(ami_content,ami_wordCount*(wordPage-1)+1,ami_wordCount)
elseif wordPage=ami_pageCount+1 then
ami_content=mid(ami_content,ami_wordCount*ami_pageCount+1,ami_wordMod)
elseif wordPage>ami_pageCount+1 and wordPage<0 then
ami_content="非法参数,请返回"
end if
response.Write ami_content
response.Write "<br>"
for i=1 to ami_pageCount+1 '页数展示
response.Write "[<a href="&action&"?"&temp&"wordPage="&i&">"&i&"</a>]"
next
response.Write "[<a href="&action&"?"&temp&"wordPage=all>单页显示</a>]"
rs.close
set rs=nothing
end function
调用函数的代码是 <%call word_pagination("amily","content",600)%>
2013-12-06
展开全部
http://www.timihome.net/html/asp/20070501/183.html编程大本营里面的有很多呢,就不给你贴出来了,你自己去好好看看吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-12-06
展开全部
读取页码后,用MID提取规定的字数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询