二胡谱美酒加咖啡:跪求 下一篇 上一篇 的代码[名字好玩吧?]

来源:百度文库 编辑:高考问答 时间:2024/05/04 06:58:14
我们常常在浏览网站文章、新闻的时候,都会发现,上一篇新闻,这下一张图片这样的代码,但不知这样的效果怎么做的。应该可以用简短的ASP语句就可以实现,但贱弟不才,实在新手,不栗赐教大家。如谁能给出这样的代码,实感3Q。

上一张图片:
下一张图片:
上一张新闻:
下一张新闻:

其实就是一个分页程序...
给你一段程序..先看看...有不明白的地方可以发消息我..
<%
if request("page")<>"" then
currentPage=cint(request("page"))
If currentpage<=0 Then currentpage=1
else
currentPage=1
end If

sql="SELECT id, title, pub_date, FileDir FROM webnews1 where pub_date<'"&year(now)&"-"&month(now)&"-"&day(now)&"'"
If newsclassid<>"" And IsNumeric(newsclassid) Then
sql=sql&" and newsclass="&newsclassid
End if
sql=sql&" ORDER BY create_date DESC"

'response.write sql

Set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,3,1
If rs.bof And rs.eof Then
response.write "<tr><td height=30 colspan=4 align=center><font color=red>暂无!</font></td></tr>"
Else
MaxPerPage=30
totalPut=rs.recordcount
if currentpage<1 then currentpage=1
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then

showContent
showpage totalput,MaxPerPage,"list.asp"

else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
'dim bookmark
'bookmark=rs.bookmark

showContent
showpage totalput,MaxPerPage,"list.asp"

else
currentPage=1

showContent
showpage totalput,MaxPerPage,"list.asp"

end if
end if
End If
rs.close
Set rs=Nothing

Sub showContent()
i=0
do while not rs.eof
If rs("pub_date")<>"" then
datess=Split(rs("pub_date"),"-")
If CInt(datess(1))<10 Then datess(1)="0"&datess(1)
If CInt(datess(2))<10 Then datess(2)="0"&datess(2)
datess1=datess(0)&"-"&datess(1)&"-"&datess(2)
End if
%>

<tr>
<td width="13" height="20"><div align="center">·</div></td>
<td width="414"><A href="/<%=rs("fileDir")%>" target="_blank"><%=rs("title")%></A></td>
<td width="89"><div align="center"><%=datess1%></div></td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
End Sub
%>
<%
function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
%>
<tr><td colspan=3 width=100% height=50>
<form method=Post action="<%=filename%>">
<input type="hidden" name="id" value="<%=newsclassid%>">
<center>
<%if CurrentPage<2 then%>
 【首页】 【上一页】 
<%else%>
 <a href="javascript:;" onclick="changepage('1');return false;">【首页】</a> 
<a href="javascript:;" onclick="changepage('<%=currentpage-1%>');return false;">【上一页】</a> 
<%
end if
if n-currentpage<1 then
%>
下一页 末页
<%else%>
<a href="javascript:;" onclick="changepage('<%=currentpage+1%>');return false;">【下一页】</a>
<a href="javascript:;" onclick="changepage('<%=n%>');return false;">【末页】</a>
<%end if%>
 【第 <strong><font color="red"><%=CurrentPage%></font> 页 共 <font color="red"><%=n%></font></strong> 页】
</td></tr></form>
<%
end function
%>

分页。。写很麻烦,从网上DOWN 一个分页程序。