
程序代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.>
<html xmlns="http://www.>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新闻广告</title>
<link href="../css/cbebcss.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#F4F4F4" leftmargin="0" topmargin="6" marginwidth="0" marginheight="0">
<%
Dim db,rs,strSql
Set db=Server.CreateObject("ADODB.Connection")
db.Open "Dsn=XX" ' XX换成你的数据库名
Set rs=Server.CreateObject("ADODB.Recordset")
strsql="select * from XX " ' XX换成你的表名
rs.Open strSql,db,1
%>
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999" align="center">
<tr bgcolor="#DBDBDB">
<td>标题</td>
<td>分类</td>
<td> 发布时间</td>' 这是表格部分你会的吧
</tr>
<%
Rs.PageSize = 3 '数字是控制一页显示的条数
If Request("PageNo") = "" Then PageNo=1 Else PageNo = CInt(Request("PageNo"))
If PageNo < 1 Then Response.Redirect "?PageNo=1"
If PageNo > Rs.PageCount And Rs.PageCount > 0 Then Response.Redirect "?PageNo=" & Rs.PageCount
If Rs.Eof and Rs.Bof Then PageNo = 0 Else Rs.AbsOlutePage = PageNo
%>
<%For x = 1 to Rs.PageSize
If Rs.Eof Then Exit For
%>
<tr bgcolor="#FFFFFF" onmouseover="this.bgColor = '#ebebeb'" onmouseout="this.bgColor = '#FFFFFF'">
<td><%=rs("title")%></td>
<td><%=rs("typestr")%></td>
<td><%=rs("uptime")%></td> '这边写与上面对应的字段名比如你的表里有个XX就写<%=rs("XX")%>
</tr>
<%rs.movenext
next%></table><table cellspacing="0" width="508" border="0" align="center">
<tr><td> </td></tr>
<tr>
<td align="center" >
<%CurrentPage= PageNo
showpage "?",rs.recordcount,Rs.PageSize,true,true,"条" %>
</td>
</tr>
</table>
<%
sub showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
dim n, i,strTemp,strUrl
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
strTemp= "<table align='center'><form name='showpages' method='Post' action='" & sfilename & "'><tr><td>"
if ShowTotal=true then
strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & " "
end if
strUrl=(sfilename)
if CurrentPage<2 then
strTemp=strTemp & "首页 上一页 "
else
strTemp=strTemp & "<a href='" & strUrl & "PageNo=1'>首页</a> "
strTemp=strTemp & "<a href='" & strUrl & "PageNo=" & (CurrentPage-1) & "'>上一页</a> "
end if
if n-currentpage<1 then
strTemp=strTemp & "下一页 尾页"
else
strTemp=strTemp & "<a href='" & strUrl & "PageNo=" & (CurrentPage+1) & "'>下一页</a> "
strTemp=strTemp & "<a href='" & strUrl & "PageNo=" & n & "'>尾页</a>"
end if
strTemp=strTemp & " 页次:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
strTemp=strTemp & " <b>" & maxperpage & "</b>" & strUnit & "/页"
if ShowAllPages=True then
strTemp=strTemp & " 转到:<select name='PageNo' size='1' onchange='javascript:submit()'>"
for i = 1 to n
strTemp=strTemp & "<option value='" & i & "'"
if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
strTemp=strTemp & ">第" & i & "页</option>"
next
strTemp=strTemp & "</select>"
end if
strTemp=strTemp & "</td></tr></form></table>"
response.write strTemp
end sub %>
</body>
</html>
这个带分页的 PS这个分页比我原来的好 呵呵 这个分页是论坛的高手教的