求助ASP长文章分页问题
就是新闻文章过长如何让它自动显示,以下是在下文章显示页的代码。其中数据库里文章内容存放字段是content,目前代码里面的<%=content%>就是简单的完全显示内容,希望能帮忙弄成可以分页显示并附带分页链接的。
网上都搜索了一大堆,可小弟愚笨,不知如何使用,所以想请大家给直接指导一下。
多谢!
代码:
<!--#include file = conn.asp -->
<!--#include file = piclist2.asp -->
<%
function chkhtm(stra)
stra=replace(stra,"<","<")
stra=replace(stra,">",">")
stra=replace(stra,"'","")
stra=replace(stra,"(","(")
stra=replace(stra,")",")")
stra=replace(stra,";",";")
stra=replace(stra,",",",")
stra=replace(stra,"%","%")
stra=replace(stra,"+","+")
chkhtm=stra
end function
newsid=trim(Request("newsid"))'获取新闻的id
id=newsid
if newsid="" then
Response.Write "<BR><BR><BR><center>参数不正确,无法找到该篇文章,请与管理员联系,谢谢!</center>"
response.end
end if
sql = "select * from news where id="&newsid
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,1
if rs.recordcount=0 then'新闻记录集为空时显示
Response.Write "<BR><BR><Center>非常抱歉.该新闻可能已被删除!<BR><BR>"
rs.close:set rs=nothing
conn.close:set conn=nothing
Response.end
end if
title="<font color="&rs("titlecolor")&">"&trim(rs("title"))&"</font>"'获取标题
webtitle=rs("title")'浏览器的标题
dat=rs("time")'日期
zz=trim(rs("zz"))'作者
ly=trim(rs("ly"))'来源
hit=rs("hit")+1'点击数
webxgnews=rs("xgnews")
if webxgnews="" then webxgnews=left(rs("title"),5)'若相关新闻的关键字为空时,自动提取标题的前5位作为关键字
Set xgrs = Server.CreateObject("ADODB.RecordSet")'xgrs是相关新闻的记录集
xgrs.Open "select top 10 * from [news] where title like '%"&webxgnews&"%' and id<>"&trim(Request("newsid"))&" order by id desc",conn,1,1
while not xgrs.eof
xgnews=xgnews + "<a href=article.asp?newsid="&xgrs("id")&" title='"&xgrs("title")&"'>"&"·"&xgrs("title")&"</a><BR>"
xgrs.movenext
wend
if xgrs.recordcount=0 then xgnews="暂无相关文章"
Set tjrs = Server.CreateObject("ADODB.RecordSet")'xgrs是相关新闻的记录集
tjlm=cstr(rs("lm"))
tjsql="select top 10 * from [news] where tj='推荐'and lm='"&tjlm& "' order by id desc"
tjrs.Open tjsql,conn,1,1
while not tjrs.eof
tjnews=tjnews + "<a href=article.asp?newsid="&tjrs("id")&" title='"&tjrs("title")&"'>"&"·"&tjrs("title")&"</a><BR>"
tjrs.movenext
wend
if tjrs.recordcount=0 then tjnews="暂无推荐文章"
content=rs("content")
url=trim(rs("url"))
conn.Execute = "update news set hit=hit+1 where ID="&newsid
if url<>"" then
Response.Redirect url
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=webtitle%>-PGonline掌机圣域</title>
<link href="css/pgonline.css" rel="stylesheet" type="text/css">
</head>
<body>
<div align="center">
<!--#include file = top.asp -->
<table width="998" border="0" cellpadding="0" cellspacing="0" class="tdround2">
<tr bgcolor="#FFFFFF">
<td width="678" valign="top"><div align="center" class="style1">
<div align="left">
<table width="673" border="0" cellpadding="0" cellspacing="1" bgcolor="#A9C9E2" class="tdroundleft">
<tr>
<td height="27" background="images/menu_bg2.gif" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td height="25" class="now"><a href="http://www.首页 </a>>
<% fatherlm=""
fatherlm2=""
lm2=rs("lm3")
if lm2="0" or lm2="" then lm2=rs("lm2")
if lm2="0" or lm2="" then lm2=rs("lm")
sql2 = "select * from lm where id="&lm2
Set rs2 = Server.CreateObject("ADODB.RecordSet")
rs2.Open sql2,conn,1,1
lm=rs2("lm")&rs2("lm2")&rs2("lm3")
pic=rs2("pic")
fatherlmid=rs2("lmid")
lm="<a href=article_list.asp?lm2="&rs2("id")&">"&lm&"</a>"
if fatherlmid>0 then
sql22 = "select * from lm where id="&fatherlmid
Set rs22 = Server.CreateObject("ADODB.RecordSet")
rs22.Open sql22,conn,1,1
fatherlm="<a href=article_list.asp?lm2="&rs22("id")&">"&rs22("lm")&"</a>"&" > "
fatherlmid=rs22("lmid")
end if
if fatherlmid>0 then
sql222 = "select * from lm where id="&fatherlmid
Set rs222 = Server.CreateObject("ADODB.RecordSet")
rs222.Open sql222,conn,1,1
fatherlm2="<a href=article_list.asp?lm2="&rs222("id")&">"&rs222("lm")&"</a>"&" > "
end if
if rs("titlecolor")="默认颜色" or rs("titlecolor")="" then
fontcolor=000000
else
fontcolor=rs("titlecolor")
end if
response.write fatherlm2&fatherlm&lm%>
<a href="http://www. </a>> 正文</td>
</tr>
</table></td>
</tr>
</table>
<table width="673" border="0" cellpadding="0" cellspacing="1" bgcolor="#A9C9E2" class="tdroundleft">
<tr>
<td bgcolor="#FFFFFF"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="55" background="images/title_bg.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center" class="TITLE"><strong><%=title%></strong></div></td>
</tr>
</table></td>
</tr>
<tr>
<td><hr align="center" width="640" size="1" noshade></td>
</tr>
<tr>
<td><table border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
<td><span class="article2">来源:</span><span class="article3"><%=ly%></span></td>
<td><span class="article2">作者:</span><span class="article3"><%=zz%></span></td>
<td><span class="article2">时间:</span><span class="article3"><%=formatdatetime(dat,2)%></span></td>
<td><span class="article2">点击:</span><span class="article3"><%=hit%></span></td>
</tr>
</table> </td>
</tr>
<tr>
<td><hr align="center" width="640" size="1" noshade></td>
</tr>
</table>
<table width="100%" height="100%" border="0" cellpadding="10" cellspacing="0">
<tr class="articlecontent">
<td><%=content%></td>
</tr>
<tr>
<td class="pgonline2"><p align="left"><strong>-------------------------------------------</strong><strong>----------------</strong><strong>----------------</strong><strong>-</strong><strong>-</strong><strong>-</strong><strong>-</strong><strong>-</strong><strong>-</strong><strong>-</strong><strong>-</strong><strong>-</strong>----------<br>
<br>
<br>
</p>
<p></p></td>
</tr>
</table></td>
</tr>
</table>
<table width="673" border="0" cellpadding="0" cellspacing="1" bgcolor="#A9C9E2" class="tdroundleft">
<tr>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="right" class="pgonline2">[<a href="#comment_new">发表评论</a>]</div></td>
</tr>
<tr>
<td height="25"><img src="images/comment_top.gif" width="669" height="25"></td>
<%
sql_pl = "select top 5 * from newspl where newsid="&clng(newsid)&"and sh=1 order by id desc"
Set rs_PL = Server.CreateObject("ADODB.RecordSet")
rs_pl.Open sql_pl,conn,1,1
%>
</tr>
<tr>
<td class="pgonline2"><table width="98%" height="100%" align="center" cellpadding="2">
<%
if rs_PL.recordcount<>0 then
for i=1 to rs_PL.recordcount
%>
<tr>
<td bgcolor="#F5F5F5"><div align="left"><img src="images/bbstitle.gif" width="16" height="16"> 第<font color="red"> <%=rs_PL("floor")%></font> 楼 <font color="#336699"><%=rs_PL("username")%></font> 发表于 <%=rs_PL("addtime")%></div></td>
</tr>
<tr>
<td><div align="left">
<%response.write left(rs_PL("content"),90)%>
<br>
</div></td>
</tr>
<%
rs_PL.movenext
if rs_PL.eof then exit for
next
else
Response.Write "<tr><td>暂无相关评论!</td></tr>"
end if
%>
</table>
<%if rs_PL.recordcount>0 then %>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td bgcolor="#F5F5F5"><div align="right"><a href=# onclick='window.open("admins/NewsPL.asp?id=<%=newsid%>","newsview","width=680,height=400,top=70,left=150,scrollbars=yes" )'>查看全部评论...</a></div></td>
</tr>
</table>
<%end if%></td>
</tr>
<tr>
<td><a name="comment_new"></a><img src="images/comment_new.gif" width="669" height="25"></td>
</tr>
<tr>
<td><table width="100%" border="0" cellpadding="4" cellspacing="4">
<tr>
<td><!--webbot BOT="GeneratedScript" PREVIEW=" " startspan -->
<script Language="JavaScript" Type="text/javascript"><!--
function FrontPage_Form1_Validator(theForm)
{
if (theForm.username.value == "")
{
alert("请输入您的网名。");
theForm.username.focus();
return (false);
}
if (theForm.username.value.length < 2)
{
alert("在“网名”框中,请至少输入2个字符。");
theForm.username.focus();
return (false);
}
if (theForm.username.value.length > 10)
{
alert("在“网名”框中,请最多输入10个字符。");
theForm.username.focus();
return (false);
}
if (theForm.content.value == "")
{
alert("请输入您的评论。");
theForm.content.focus();
return (false);
}
if (theForm.content.value.length < 5)
{
alert("在“评论”框中,请至少输入5个字符。");
theForm.content.focus();
return (false);
}
if (theForm.content.value.length > 1000)
{
alert("在“评论”框中,请最多输入1000个字符。");
theForm.content.focus();
return (false);
}
return (true);
}
//--></script>
<!--webbot BOT="GeneratedScript" endspan -->
<form action="admins/NewsPL_save.asp?id=<%=id%>" method="POST" name="FrontPage_Form1" target="_top" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript">
<div align="center">
<table width="100%" border="1" cellpadding="5" bordercolor="#C0C0C0" bgcolor="#F5F5F5" id="table1" style="border-collapse: collapse">
<tr>
<td width="79" align="center" class="pgonline2">网 名</td>
<td width="453"><!--webbot bot="Validation" s-display-name="作者" b-value-required="TRUE" i-minimum-length="2" i-maximum-length="8" -->
<div align="left">
<input type="text" name="username" size="20" style="background-color: #F5F5F5" maxlength="8">
</div></td>
</tr>
<tr>
<td width="79" align="center" bgcolor="#FFFFFF" class="pgonline2">评论</td>
<td bgcolor="#FFFFFF"><div align="left"><span class="pgonline2">(最多1000字)<BR>
</span>
</div>
<div align="left"> <span class="pgonline2">
<textarea rows="4" name="content" cols="50"></textarea>
</span></div>
<div align="left"><br>
<span class="style4">注:所有评论通过审核后才会被公开。</span></div></td>
</tr>
</table>
</div>
<p align="center">
<input type="submit" value="提交" name="B1">
<input type="reset" value="重置" name="B2">
</p>
</form></td>
<td valign="top"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="pgonline2"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</div>
</div> </td>
<td width="409" valign="top"><table width="315" border="0" cellpadding="0" cellspacing="0" class="tdroundright">
<tr>
<td><a href="ly.asp" target="_blank"><img src="images/ad/ad_ly.gif" alt="法律咨询" width="315" height="100" border="0" longdesc="ly.asp"></a></td>
</tr>
</table>
<table width="315" border="0" cellpadding="0" cellspacing="1" bgcolor="#A9C9E2" class="tdroundright">
<tr>
<td height="25" background="images/other_menu.gif" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="menu3"><div align="left"><img src="images/spacer.gif" alt="" width="6" height="1">最新图文</div></td>
</tr>
</table></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td height="152" valign="top" class="bh"><div align="left"><span class="bh"><span class="pgonline1">
<%response.write piclist(rs("lm"),2,100,0,0,150,80)%>
</span>
</span></div></td>
</tr>
</table></td>
</tr>
</table>
<table width="315" border="0" cellpadding="0" cellspacing="1" bgcolor="#A9C9E2" class="tdroundright">
<tr>
<td height="25" background="images/other_menu.gif" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="menu3"><div align="left"><img src="images/spacer.gif" alt="" width="6" height="1">相关文章</div></td>
</tr>
</table></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td height="152" valign="top" class="bh"><div align="left"><span class="bh">
<%response.write xgnews%>
</span></div></td>
</tr>
</table></td>
</tr>
</table>
<table width="315" border="0" cellpadding="0" cellspacing="1" bgcolor="#A9C9E2" class="tdroundright">
<tr>
<td height="25" background="images/other_menu.gif" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="menu3"><div align="left"><img src="images/spacer.gif" alt="" width="6" height="1">本类推荐</div></td>
</tr>
</table></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td height="152" valign="top" class="bh"><div align="left">
<%response.write tjnews%>
</div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</div>
<!--#include file = bottom.asp -->
<%
xgrs.close
tjrs.close
rs_pl.close
rs.close
set conn=nothing
%>
</body>
</html>