JSP Paging program code
<%@ page contenttype= "text/html; charset=gb2312 "language=" java "import=" java.sql.* "errorpage=" "%>"
<% @include file = ". /inc/chkpwd.jsp "%>
<% @include file= ". /db.jsp "%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta name= "Robots" content= "Noindex,nofollow"/>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Article Management </title>
<link href= "Style.css" rel= "stylesheet" type= "Text/css"/>
<body>
<table width= "98%" height= "77%" border= "0" cellpadding= "0" cellspacing= "0" >
<tr class= "STYLE1" >
<TD width= "100% height=" background= "images/admin_bg_1.gif" ><strong><font color= "#FFFFFF" >-- <span class= "STYLE1" > Content Management </span></font></strong></td>
</tr>
<tr>
<TD colspan= "Ten" >
</td>
</tr>
<tr class= "title" >
<TD height= "background=" Images/admin_bg_1.gif "class=" "T2" >|
<%
String op;
String id = request.getparameter ("id");
OP = Request.getparameter ("op");
if (op==null) {
OP = "my";
}
if (Op.equals ("del") && id!=null) {
string bbb = new String (Request.getparameter ("Bigclassname"). GetBytes ("Iso8859_1"));
Statement stmt_channeldel=conn.createstatement ();
String sqldel= "Delete from hl_news where id=" + ID;
int shan=stmt_channeldel.executeupdate (Sqldel);
if (shan>0)
{
Out.print ("<script type=" Text/javascript "> Alert (") was successfully deleted! "); Window.location.href= ' hanye_manages.jsp? Bigclassname= "+bbb+"; </script> ");
}
Stmt_channeldel.close ();
return;
}
Statement stmta=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_read_only);
String sqla= "SELECT * from Hl_smallclass WHERE bigname= ' industry News ' ORDER by ID ASC";
ResultSet rsa=stmta.executequery (SQLA);
while (Rsa.next ()) {
%>
<a class= ' T2 ' href= ' hanye_manages.jsp?modi= news &bigclassname=<%=rsa.getstring ("Smallname")%> ' >< %=rsa.getstring ("Smallname")%></a> |
<%
}
Rsa.close (); Close Recordset object
Stmta.close (); Close Statement Object
%>
</td>
</tr>
<tr>
<TD height= "></td>"
</tr>
<tr>
<TD align= "center" valign= "Top" bgcolor= "#ECF5FF" >
<form name= "Form2" action= "list.asp?action=delall&modi= News" method= "POST" >
<table width= "100%" cellpadding= "3" cellspacing= "2" bgcolor= "#FFFFFF" style= "Word-break:break-all" >
<tr class= "T2" >
<TD width= "height=" align= "center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > Id</td>
<TD width= "align=" "Center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > News category </TD >
<TD width= "align=" "Center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > News small Class </td >
<TD width= "291" align= "center" background= "Images/admin_bg_1.gif" "bgcolor=" #BBDAFF "class=" STYLE1 "style=" Word-break:break-all "> News headlines </td>
<TD width= "179" align= "center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > News pictures </ Td>
<TD width= "align=" "Center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > Release time </TD >
<TD width= "align=" "Center" background= "Images/admin_bg_1.gif" bgcolor= "#BBDAFF" class= "STYLE1" > Operation </td >
</tr>
<%
int pagesize=10; Number of articles displayed per page
int showpage=1; The page number displayed on the current page
int reccount=0; Total number of articles in resultset
int pagecount=0; Total pages after pagination
String sqlarticle;
String topage = request.getparameter ("page");
String bgname = new String (Request.getparameter ("Bigclassname"). GetBytes ("Iso8859_1"));
Statement stmt_article=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_read_only);
Sqlarticle= "SELECT * from Hl_news where smallname= ' +bgname+" ' ORDER by ID DESC ";
ResultSet rsarticle=stmt_article.executequery (sqlarticle);
if (Rsarticle.next ()) {
Rsarticle.last ()//The pointer flies to the last
Reccount=rsarticle.getrow ()//Remove line number from last line
Pagecount= (reccount%pagesize) ==0? ( reccount/pagesize):(reccount/pagesize) +1)//How many pages can be divided
if (topage!=null)
Showpage=integer.parseint (ToPage);
Rsarticle.absolute ((showPage-1) *pagesize+1);//Skip to page one of ShowPage
for (int i=1;i<=pagesize;i++) {
int Nid=rsarticle.getint ("ID");
String img = rsarticle.getstring ("img");
String TTT = Rsarticle.getstring ("Times");
Ttt=ttt.substring (0,10);
%>
<tr class= "STYLE1" >
<TD width= "height=" align= "center" bgcolor= "#BBDAFF" ><%=NID%></td>
<TD align= "center" bgcolor= "#BBDAFF" ><%=rsarticle.getstring ("Bigname")%></td>
<TD align= "center" bgcolor= "#BBDAFF" ><%=rsarticle.getstring ("Smallname")%></td>
<TD align= "left" bgcolor= "#BBDAFF" ><%=rsarticle.getstring ("Title")%></td>
<TD align= "center" bgcolor= "#BBDAFF" ><a href= "/<%=img%>" target= "_blank" ><%=img%></a ></td>
<TD align= "center" bgcolor= "#BBDAFF" ><%=ttt%></td>
<TD width= "align=" center "bgcolor=" #BBDAFF "class=" STYLE1 "><a href=" hanye_edit.jsp?id=<%=nid%> &modi= News "> Modify </a>|<a href=" hanye_manages.jsp?id=<%=nid%>&op=del&bigclassname=<% =bgname%> "onclick=" return confirm (' Delete will not be restored, are you sure to delete it? ') ' > Delete </a></td>
</tr>
<%
if (! Rsarticle.next ())
Break
}
}
%>
<input name= ' allid ' type= ' hidden ' value=>
</table>
<table width= "100%" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr class= "STYLE1" >
<TD width= "50%" align= "left" background= "Images/admin_bg_1.gif" >
<span class= "T2" ><strong></strong>
</span>
<label>
</label>
</td>
<TD width= "56%" align= "center" background= "Images/admin_bg_1.gif" >
<div align= "left" class= "T2" >
Total <%=pageCount%> page <% for (int i=1;i<=pagecount;i++) {%> <% if (i==showpage) {%><b><%=i% ></b><%}else{%>[<a href= ' hanye_manages.jsp? Bigclassname=<%=bgname%>&page=<%=i%>&modi= News ' ><%=i%></a>] <%}}%>
</div></td>
</tr>
</table>
</form>
<form name= "Form1" method= "Post" action= "hanye_manage.jsp" > <table width= "51%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr class= "T4" >
Width= "34%" height= "<TD" ><span class= "STYLE1" > Enquiry:</span>
<label>
<select name= "Select" >
<option value= "id" > by ID query </option>
<option value= "title" > Query by Title </option>
<option value= "Times" > Query by Time </option>
</select>
</label>
<label>
<input type= "text" name= "K" >
<input name= "Submit" type= "Submit" class= "T5" value= "submitted" >
</label> </td>
</tr>
</table>
</form>
<br></td>
</tr>
</table>
<%
Rsarticle.close ();
Stmt_article.close ();
Conn.close ();
%>
</body>