<% @ Page import = "java. SQL. *, java. io. *, java. util. *" %>
<% @ Page language = "java" pageEncoding = "Big5" %>
<%! String au_id, au_lname, au_fname, phone, address, city, state; %>
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> ArticleList </TITLE>
<Link rel = "stylesheet" href = "style.css">
</Head>
<Body bgcolor = "# FFFFFF"> <table width = "760" border = "0" cellspacing = "0" cellpadding = "0" align = "center">
<Tr>
<Td>
<Table width = "750" border = "0" cellspacing = "2" cellpadding = "2" align = "center">
<Tr align = "center">
<Td> & nbsp; </td>
</Tr>
<Tr>
<Td>
<Table width = "740" border = "0" cellspacing = "1" cellpadding = "1" align = "center">
<Tr align = "center" bgcolor = "# CCCCCC">
<Td> <B> title </B> </td>
<Td> <B> author </B> </td>
<Td> <B> type </B> </td>
<Td> <B> click </B> </td>
<Td> <B> join time </B> </td>
</Tr>
<%
Int I;
Int ipage = 5; // page unit
Int allpage; // the total number of pages.
Int pages; // The accepted page number variable.
Int cpage = 1; // current page
Int spage; // start page
Int allCol = 0;
Vector v = null; // database connection Declaration
Connection conn = null;
Java. lang. String SQL, pagesql;
Java. SQL. ResultSet rs, pagers;
Statement statement = null;
String kmsdb = "jdbc: microsoft: sqlserver: // 127.0.0.1: 1433; DatabaseName = DBName ";
Class. forName ("com. microsoft. jdbc. sqlserver. SQLServerDriver ");
Conn = DriverManager. getConnection (kmsdb, "user", "pwd ");
Pagesql = "select count (*) FROM Authors"; // retrieve the total number of articles
Statement = conn. createStatement ();
Pagers = statement.exe cuteQuery (pagesql );
While (pagers. next ())
{
AllCol = pagers. getInt (1 );
System. out. println (allCol );}
// Obtain the total number of pages
Allpage = (int) Math. ceil (allCol + ipage-1)/ipage );
// Determine whether the parameter pages is null
If (request. getParameter ("pages") = null ){
Pages = 1;
} Else {
Pages = new Integer (request. getParameter ("pages"). intValue ();
System. out. println (pages );
}
// Determine the current page
If (pages> allpage | pages = 0)
{Cpage = 1 ;}
Else
{
Cpage = pages;
}
// Determine the start page
SQL = "select Top" + ipage + "au_id, au_lname, au_fname, address, phone from authors where au_id not in (select top" + (cpage-1) * ipage + "au_id from authors order by au_id desc) order by au_id desc ";
Rs = statement.exe cuteQuery (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 = "300"> <% = au_id %> </a> </td>
<Td width = "300"> <% = au_lname %> </a> </td>
<Td width = "300"> <% = au_fname %> </a> </td>
<Td width = "300"> <% = phone %> </a> </td>
<Td width = "300"> <% = address %> </a> </td>
</Tr>
<%
} %>
<Tr bgcolor = "# CCCCCC">
<Td colspan = "5" align = "right" valign = "middle"> total <% = allCol %> records <% = allpage %> page <% if (cpage> 1) {%> <a href = "fy. jsp? Pages = <% = cpage-1 %> "> </a> <%} if (cpage <allpage) {%> <a href = "fy. jsp? Pages = <% = cpage + 1%> </a> <% }%>/<% for (I = 1; I <= allpage; I ++) {if (I! = Pages) {%> <a href = "fy. jsp? Pages = <% = I %> "> <% = I %> </a> & nbsp; <% }%> </td>
</Tr>
</Table>
</Td>
</Tr>
</Table>
</Td>
</Tr>
</Table>
</Body>
</Html>