3 回答

TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超2個(gè)贊
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
sitePath="data.mdb"
dim conn
set conn=server.CreateObject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0; data source="&server.mappath("/"&sitePath)
set rs=server.CreateObject("adodb.recordset")
sql="select * from Aspcms_News where NewsID=5 "
rs.open sql,conn,1,1
if not rs.eof then
numbers=len(rs("content")) '總字節(jié)數(shù)
pagenum=900 '每頁(yè)顯示的數(shù)量
maxpage=-int(-numbers/pagenum)'總頁(yè)數(shù)
requestpage=clng(request("p"))'接收頁(yè)碼
if requestpage="" or requestpage=0 then'獲取默認(rèn)頁(yè)碼
requestpage=1
end if
if requestpage>maxpage then '當(dāng)前頁(yè)的頁(yè)碼大于最大頁(yè)碼時(shí),使當(dāng)前頁(yè)碼等于最大頁(yè)碼
requestpage=maxpage
end if
if not requestpage=1 then '當(dāng)前頁(yè)碼不等于1時(shí),向下移動(dòng)相應(yīng)的字節(jié)數(shù)
content=mid(rs("Content"),(requestpage-1)*pagenum+1,900)
else
content=left(rs("Content"),900) '當(dāng)頁(yè)碼等于1時(shí),截取相應(yīng)文本
end if
if isempty(requestpage) then
thispage=1
else
thispage=cint(requestpage)
end if
%>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>對(duì)超長(zhǎng)文本數(shù)據(jù)進(jìn)行分頁(yè)顯示</title>
</head>
<body >
<table width="470" border="0" cellspacing="0">
<tr>
<td height="33"><div align="center"><strong><%=rs("Title")%></strong></div></td>
</tr>
<tr>
<td> <font size="2"><%' =content%><%=Replace(content,chr(13),"<br>")%></font></td>
</tr>
<tr>
<td align="right">
<font size="2">總頁(yè)數(shù):<%=maxpage%> 當(dāng)前頁(yè):<%=requestpage%> <a href="content_page.asp?p=1">第一頁(yè)</a> <a href="content_page.asp?p=<%=(requestpage-1)%>">上一頁(yè)</a> <a href="content_page.asp?p=<%=(requestpage+1)%>">下一頁(yè)</a> <a href="content_page.asp?p=<%=maxpage%>">最后一頁(yè)</a></font>
</td>
</tr>
<tr>
<td align="right">
<%for i=1 to maxpage
if thispage=i then
response.write ""&i&" "
else %>
[<a href="content_page.asp?p=<%=i%>"><%=i%></a>]
<% end if %>
<%next%>
</td>
</tr> </table>
<%
else
response.Write("沒(méi)有內(nèi)容")
end if
%>
</body></html>
我參考的這個(gè)代碼,可以正常分頁(yè),卻有html代碼
- 3 回答
- 0 關(guān)注
- 606 瀏覽
添加回答
舉報(bào)