=*最新新闻*=<br/>
<%
Set rs=conn.execute("Select Top 10 ID,title From [NewsContent] order by ID desc") '读取新闻内容表前十条记录
While(Not rs.eof) '//循环列出新闻标题
%>
<a href="NewsShow.asp?ID=<%=rs(0)%>"><%=rs(1)%></a><br/>
<%
rs.moveNext
Wend
Call rsClose()
Call connClose()
%>
<%
Dim ID,rs
ID=int(request.QueryString("ID"))
Call openConn() '打开数据库
Response.Write (conn.execute("Select Name from [NewsType] where ID="& ID &"")(0))&"新闻列表
<br/>" '输出类别名
%>
=*=*=*=*=*=<br/>
<%
Set rs=conn.execute("Select ID,title From [NewsContent] where typeID="& ID &" order by ID
desc") '读取新闻内容表
If Not rs.eof Then
Dim i,PageSize
PageSize=10 '每一页显示的条数
For i=1 To PageSize '根据每一页的条数进行循环
If rs.eof Then Exit For '如果循环到了尽头,则跳出循环
%>
<a href="NewsShow.asp?ID=<%=rs(0)%>"><%=rs(1)%></a><br/>
<%
rs.moveNext '游标指到下一条记录
Next
Else
%>
暂时没有新闻!
<%
End If
Call rsClose()
Call connClose()
%>
现在,我们插入分页代码。在PageSize=10 和 For i=1 To PageSize之间插入以下代码:
Dim Count,page,pagecount,gopage '定义相关变量
gopage="NewsList.asp?ID="&ID&"&"
Count=conn.execute("Select count(ID) from [NewsContent] where typeID="& ID &"")(0)
'读取新闻总数
page=int(request.QueryString ("page"))
if page<=0 or page="" then page=1 '默认为第一页
pagecount=(count+pagesize-1)\pagesize '计算出页数
rs.move(pagesize*(page-1)) '将游标指到每一页的第一条记录
<%
Dim ID,rs,i,typeID,content '定义变量
ID=int(request.QueryString("ID"))
Call openConn() '打开数据库
Set rs=conn.execute("Select typeID,title,content,comment From [NewsContent] where ID="& ID &"") '读取新闻内容表
If Not rs.eof Then
typeID=rs(0)
content=rs(2) '将新闻内容传给变量content
Response.Write (rs(1)&"<br/>=*=*=*=*=*=<br/>"&Replace(content,chr(13),"<br/>")) '将内容中的回车替换成换行
Else
typeID=1
Response.Write ("该新闻不存在")
End If
Call rsClose()
Call ConnClose()
%>
If content="" Then
Response.Write ("内容不能为空!<br/>=*=*=*=*=*=<br/>")
Response.Write ("<anchor title=""返回上一页"">返回上一页<prev/></anchor><br/>")
Response.Write ("<a href=""NewsShow.asp?ID="& ID &""">返回新闻内容</a><br/>"&_
"<a href=""index.asp"">返回网站首页</a><br/>"&_
"</p></card></wml>") wap资源:www.7wap.cn
Response.End
End If
Call openConn() '打开数据库
Conn.Execute("Insert Into [NewsComment] (newsID,content) values("& ID &",'"& content &"')")
Call ConnClose()
Response.Write ("回复成功!<br/>=*=*=*=*=*=<br/>")
Response.Write ("<anchor title=""返回上一页"">返回上一页<prev/></anchor><br/>")
Response.Write ("<a href=""NewsShow.asp?ID="& ID &""">返回新闻内容</a><br/>"&_
"<a href=""index.asp"">返回网站首页</a><br/>"&_
"</p></card></wml>")
最后,就是回复的显示跟回复列表文件了。
先打开NewsShow.asp文件,在快速回复上面,即Response.Write("<br/>=*=*=*=*=*=<br/>"),插入以下代码:
'//读取最后一条回复
Dim rsReply
Set rsReply=conn.execute("Select top 1 content from [NewsComment] where newsID="& ID &" order by ID desc") 7WAP
If Not rsReply.eof Then
Response.Write("<br/>=*=*=*=*=*=<br/>")
Response.Write ("最新回复:<br/>"&_
replaceStr(rsReply(0))&"<br/>"&_
"<a href=""ReplyList.asp?ID="& ID &""">阅读所有回复</a>")
End If
rsReply.close()
set rsReply=nothing
Call openConn() '打开数据库
Set rs=conn.execute("Select content From [NewsComment] where newsID="& ID &"") '读取新闻回复表
If Not rs.eof Then
Dim PageSize,i
PageSize=10 '每一页显示的条数
Dim Count,page,pagecount,gopage '定义相关变量
gopage="ReplyList.asp?ID="&ID&"&"
Count=conn.execute("Select count(ID) from [NewsComment] where newsID="& ID &"")(0) '读取回复总数
page=int(request.QueryString ("page"))
if page<=0 or page="" then page=1 '默认为第一页
pagecount=(count+pagesize-1)\pagesize '计算出页数
rs.move(pagesize*(page-1)) '将游标指到每一页的第一条记录
For i=1 To PageSize '根据每一页的条数进行循环
If rs.eof Then Exit For '如果循环到了尽头,则跳出循环
Response.Write (i+(PageSize*(page-1))&"."&replaceStr(rs(0))&_
"<br/>-=-=-=-=-=-<br/>")
rs.moveNext
Next
本文章首发:http://www.7wap.cn,WAP资讯网
response.write ("共:"&count&"条,"&page&"/"&pagecount&"页")
if page-pagecount<0 then response.write "<br/><a href="""&gopage&"page="&page+1&""">下页-</a><a
href="""&gopage&"page="&pagecount&""">尾页</a>"
if page>1 then response.write "<br/><a href="""&gopage&"page="&page-1&""">上页-</a><a href="""&gopage&"page=1"">首页
</a>"
'//下面这一句,是让用户通过输入框输入页数,然后通过链接直接转向该页
if pagecount>1 then response.write "<br/><input name=""page"" format=""*N"" value="""&page&""" type=""text""
maxlength=""5"" emptyok=""true""/><br/><a href="""&gopage&"page=$(page)"">[跳转到该页]</a>" wap资源:www.7wap.cn
Else
Response.Write ("暂无回复内容!")
End If
Call rsClose()
Call ConnClose()
'//读取最后一条回复
Dim rsReply
Set rsReply=conn.execute("Select top 1 content from [NewsComment] where newsID="& ID &" order by ID desc")
If Not rsReply.eof Then
Response.Write("<br/>=*=*=*=*=*=<br/>")
Response.Write ("最新回复:<br/>"&_
replaceStr(rsReply(0))&"<br/>"&_
"<a href=""ReplyList.asp?ID="& ID &""">阅读所有回复</a>")
End If
rsReply.close()
set rsReply=nothing
Call openConn() '打开数据库
Set rs=conn.execute("Select content From [NewsComment] where newsID="& ID &"") '读取新闻回复表
If Not rs.eof Then
Dim PageSize,i
PageSize=10 '每一页显示的条数
Dim Count,page,pagecount,gopage '定义相关变量
gopage="ReplyList.asp?ID="&ID&"&"
Count=conn.execute("Select count(ID) from [NewsComment] where newsID="& ID &"")(0)'读取回复总数
page=int(request.QueryString ("page"))
if page<=0 or page="" then page=1 '默认为第一页
pagecount=(count+pagesize-1)\pagesize '计算出页数
rs.move(pagesize*(page-1)) '将游标指到每一页的第一条记录
For i=1 To PageSize '根据每一页的条数进行循环
If rs.eof Then Exit For '如果循环到了尽头,则跳出循环
Response.Write (i+(PageSize*(page-1))&"."&replaceStr(rs(0))&_
"<br/>-=-=-=-=-=-<br/>")
rs.moveNext
Next
response.write ("共:"&count&"条,"&page&"/"&pagecount&"页")
if page-pagecount<0 then response.write "<br/><a href="""&gopage&"page="&page+1&""">下页-</a><a
href="""&gopage&"page="&pagecount&""">尾页</a>"
if page>1 then response.write "<br/><a href="""&gopage&"page="&page-1&""">上页-</a><a href="""&gopage&"page=1"">首页
</a>"
'//下面这一句,是让用户通过输入框输入页数,然后通过链接直接转向该页
if pagecount>1 then response.write "<br/><input name=""page"" format=""*N"" value="""&page&""" type=""text""
maxlength=""5"" emptyok=""true""/><br/><a href="""&gopage&"page=$(page)"">[跳转到该页]</a>"
Else
Response.Write ("暂无回复内容!")
End If
Call rsClose()
Call ConnClose()