<%@ page import="java
sql
*
java
io
*
java
util
*" %>
<%@ page language="java" pageEncoding="Big
" %>
<%! String au_id
au_lname
au_fname
phone
address
city
state;%>
<!DOCTYPE HTML PUBLIC "
//W
C//DTD HTML
Transitional//EN">
<HTML>
<HEAD>
<TITLE>ArticleList</TITLE>
<link rel="stylesheet" href="style
css">
</head>
<body bgcolor="#FFFFFF"><table width="
" border="
" cellspacing="
" cellpadding="
" align="center">
<tr>
<td>
<table width="
" border="
" cellspacing="
" cellpadding="
" align="center">
<tr align="center">
<td> </td>
</tr>
<tr>
<td>
<table width="
" border="
" cellspacing="
" cellpadding="
" align="center">
<tr align="center" bgcolor="#CCCCCC">
<td><b>标题</b></td>
<td><b>作者</b></td>
<td><b>类型</b></td>
<td><b>点击</b></td>
<td><b>加入时间</b></td>
</tr>
<%
int i;
int ipage=
; //分页单位
int allpage; //总页数
int pages; //接受的页码变数
int cpage=
; //当前页
int spage; //开始页
int allCol=
;
Vector v=null;//资料库连接声明
Connection conn=null;
java
lang
String sql
pagesql;
java
sql
ResultSet rs
pagers;
Statement statement=null;
String kmsdb="jdbc:microsoft:sqlserver://
:
;DatabaseName=DBName";
Class
forName("com
microsoft
jdbc
sqlserver
SQLServerDriver");
conn = DriverManager
getConnection(kmsdb
"user"
"pwd");
pagesql = "SELECT COUNT(*) FROM Authors";//取总文章数
statement = conn
createStatement();
pagers = statement
executeQuery(pagesql);
while(pagers
next())
{
allCol = pagers
getInt(
);
System
out
println(allCol);}
//获得总页面数
allpage = (int)Math
ceil((allCol + ipage
) / ipage);
//判断参数pages是否空
if (request
getParameter("pages")==null) {
pages=
;
} else {
pages = new Integer(request
getParameter("pages"))
intValue();
System
out
println(pages);
}
//判断当前页
if(pages > allpage || pages ==
)
{cpage =
;}
else
{
cpage = pages;
}
//判断起始页
sql = "select Top "+ipage+" au_id
au_lname
au_fname
address
phone from authors where au_id not in (select top "+(cpage
)*ipage+" au_id from authors order by au_id desc)order by au_id desc";
rs = statement
executeQuery(sql);
while (rs
next())
{
au_id=rs
getString("au_id");
au_lname=rs
getString("au_lname");
au_fname=rs
getString("au_fname");
phone=rs
getString("phone");
address=rs
getString("address");%>
<td width="
"><%= au_id %></a></td>
<td width="
"><%= au_lname %></a></td>
<td width="
"><%= au_fname %></a></td>
<td width="
"><%= phone %></a></td>
<td width="
"><%= address %></a></td>
</tr>
<%
}%>
<tr bgcolor="#CCCCCC">
<td colspan="
" align="right" valign="middle">共 <%= allCol %>条记录 共 <%= allpage %>页 <% if (cpage>
) { %><a href="fy
jsp?pages=<%= cpage
%>"><img src="% } if (cpage<allpage) { %><a href="fy
jsp?pages=<%= cpage+
%>"><img src="% } %> / <% for (i=
;i<=allpage;i++) { if (i != pages) {%><a href="fy
jsp?pages=<%= i %>"><%= i %></a> <% }} %></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>