模特七十二小时bt:网页制作-分页

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/05 09:19:56
<table width="92%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="font2"><%=checkstr(content, "1")%> </td>
</tr>
</table>
<%
sql = "select top 1 prono from product where classcode='"& classcode &"' and sortnum < "& sortnum &" and state='1' order by classcode asc, sortnum desc"
rs.Open sql,cn,0,1,1
if not rs.EOF then
%>
<table width="92%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" class="font2"><a href="<%=menu%>_display.asp?prono=<%=rs("prono")%>"><img src="images/products/bt_1.gif" width="111" height="23" border="0"></a></td>
</tr>
</table>

上面代码是我一程序的里,实现的效果是:下一页

我想在起基础上实现 上一页
代码不知道怎么写,向大家请教了,谢谢大家帮忙!

把下列code保存成p_index.asp 100%工作

<%@LANGUAGE="VBScript" codepage="936"%>
<!--#include file="ubbcode.asp"-->
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Page-Exit" content="revealTrans(Duration=1.0,Transition=12)">
<script language=javascript>
var currentpos,timer;

function initialize()
{
timer=setInterval("scrollwindow()",90);
}
function sc(){
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>
<link href="skin_1.css" rel="stylesheet" type="text/css">
<title>DenReakun</title>
<link href="style.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FDFDFD" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<%
'**********************************************************

'**********************************************************
dim rs
dim sql
msg_per_page = 2
set rs = server.createobject("adodb.recordset")
sql = "select * from news where user = 'Products' order by id desc"
rs.cursorlocation = 3

rs.pagesize = msg_per_page
rs.open sql,conn,0,1

if err.number<>0 then
response.write "Database Error:" & err.description
err.clear
else
if not (rs.eof and rs.bof) then
totalrec = RS.RecordCount
if rs.recordcount mod msg_per_page = 0 then
n = rs.recordcount\msg_per_page
else
n = rs.recordcount\msg_per_page+1
end if

currentpage = request("page")
If currentpage <> "" then
currentpage = cint(currentpage)
if currentpage < 1 then
currentpage = 1
end if
if err.number <> 0 then
err.clear
currentpage = 1
end if
else
currentpage = 1
End if
if currentpage*msg_per_page > totalrec and not((currentpage-1)*msg_per_page < totalrec)then
currentPage=1
end if
rs.absolutepage = currentpage 'absolutepage:

rowcount = rs.pagesize 'pagesize:
dim i
dim k
%>
<table width="306" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="10"></td>
</tr>
</table>
<%do while not rs.eof and rowcount > 0%>
<table width="665" border="0" cellspacing="0" cellpadding="1">
<tr>
<td class="xndyk"><table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td> <img src="images/003.gif" width="9" height="9"> <%=rs("title")%></td>
</tr>
<tr>
<td height="1" background="images/heng-dian.gif"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><%=UBBCode(rs("text"))%><br>
<div align="right"><font color="#999999"><%=rs("data")%></font></div> </td>
</tr>
</table></td>
</tr>
</table>
<table width="665" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="15"></td>
</tr>
</table>
<%
rowcount=rowcount-1
rs.MoveNext
loop
end if
end if
rs.close
set rs=nothing
%>

</table>
<table border="0" align=right>
<tr>
<td valign="middle" align=right>
<%call listPages()%>
</td>
</tr>
</table>
</body>
</html>
<%
sub listPages()
'if n <= 1 then exit sub
for i=0 to n\msg_per_page-1
for j=1 to msg_per_page
%>
<font size="2" color="#006600">
<a href="<%=request.ServerVariables("script_name")%>?page=<%=i*msg_per_page+j %>">
[<% =i*msg_per_page+j %>]</a></font>
<%
next
next
EndPage = n mod msg_per_page
for j=1 to EndPage
%>
<font size="2" color="#006600">
<a href="<%=request.ServerVariables("script_name")%>?page=<% =i*msg_per_page+j %>">
<%if (i*msg_per_page+j)=currentpage then%><b><%else%><%end if%>[<% =i*msg_per_page+j %>]</b></a></font>
<%next%>
<font color=black face="arial" >
<br>Current page:<font color=#FF000000><%=currentpage%>/<%=n%></font> Total log:<font color=#FF000000><%=totalrec%></font> piece
</font>Each Page:<font color=#FF000000>2</font><font face="arial" color="black"> </font>piece
<%end sub%>

==================
记得给分啊 !