JSP Paging program code

Source: Internet
Author: User
Tags stmt

JSP Paging program code

<%
String s;
String theURL;
Theurl= "products.jsp";
S=request.getparameter ("s");
if (s!=null) {
S=new String (Request.getparameter ("s"). GetBytes ("iso-8859-1"));
Theurl= "products.jsp?s=" +s;
}
Statement stmt=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_read_only);
ResultSet rs=stmt.executequery ("select * from Hl_smallclass WHERE modiname= ' products '");
while (Rs.next ()) {
String smallname = rs.getstring ("Smallname");
%>
<tr>
&LT;TD height= "align=" center "style=" Background:url (images/ntb_bg.jpg) no-repeat Center "><a href=" Products.jsp?modi= Products &b=<%=rs.getstring ("Bigname")%>&s=<%=smallname%> ' >::<%=smallname %>::</a></td>
</tr>
<%
}
Rs.close ();
%>
</table>
</td>
&LT;TD width= "687" rowspan= "2" align= "center" valign= "Top" bgcolor= "#FFFFFF" style= "background: #fff URL (images/main_ bg.jpg) repeat-x top; " ><table style= "margin-top:5px" width= "98%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
&LT;TD width= "4%" height= "align=" center "style=" Border-bottom: #ebebeb 1px solid "></td>
&LT;TD width= "96%" align= "left" style= "Border-bottom: #ebebeb 1px solid" ><a href= "index.jsp" > Home </a> &gt; <a href= "products.jsp" > Product show </a> &gt; <% if (s!=null) {out.print (s);}%></td>
</tr>
<tr>
&LT;TD colspan= "2" align= "center" ><table width= "+" border= "0" cellpadding= "0" cellspacing= "0" style= " Border-bottom: #E7E7E7 1px solid;margin-top:15px; " >
<tr>
&LT;TD height= align= "center" > Below is our company <% if (s!=null) {out.print (s);} if (S==null) {%> all <%}%> products; click the corresponding Picture or text Enter view detailed product information </td>
</tr>
</table>
<table style= "margin-top:5px" width= "100%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
&LT;TD align= "center" valign= "Top" >


<table style= "margin-top:8px" width= "96%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
<%
int pagesize=9;
int showpage=1;
int reccount=0;
int t=0;
int pagecount=0;
String topage = request.getparameter ("page");
String SQLP;
Sqlp= "SELECT * from Hl_product ORDER by ID Desc";
if (s!=null) {
Sqlp= "SELECT * from hl_product WHERE smallname= '" +s+ "";
}
ResultSet rsa=stmt.executequery (SQLP);
if (Rsa.next ()) {
Rsa.last ();
Reccount=rsa.getrow ();
Pagecount= (reccount%pagesize) ==0? ( reccount/pagesize):(reccount/pagesize) +1);
if (topage!=null)
Showpage=integer.parseint (ToPage);
Rsa.absolute ((showPage-1) *pagesize+1);
for (int i=1;i<=pagesize;i++) {
String TTT = rsa.getstring ("title");
Ttt=ttt.substring (0,10);
int Id=rsa.getint ("ID");
%>
&LT;TD align= "Left" >
<table style= "margin-top:15px width=" 143 "height=" "border=" 0 "cellpadding=" 0 "cellspacing=" 0 "bgcolor=" # F5f5f5 ">
<tr>
&LT;TD height= "align=" "Center" ><table width= "138" border= "0" cellpadding= "0" cellspacing= "0" class= "k_a_1" >
<tr>
&LT;TD height= "align=" "Center" bgcolor= "#FFFFFF" ><a target= "_blank" href= "proshow.jsp?id=<%=id%>" ></a></td>
</tr>
</table></td>
</tr>
<tr>
&LT;TD height= "align=" "Center" class= "F-12-black" ><a target= "_blank" href= "proshow.jsp?id=<%=id%>" ><%=rsa.getstring ("title")%></a></td>
</tr>
</table>
</td>

<%
t++;
if (i%3==0) out.print ("</tr><tr>");

if (! Rsa.next ())
Break
}

}
Rsa.close ();
%>

<tr>
</table>



<table align= "center" >
<form
action= "News.asp?classid=&amp;bigclassname= News Online"
Method= "POST" name= "Showpages" id= "Showpages" >
<tbody>
<tr>
                       <td><% if (showpage>1) {%><a class= ' f-12-black ' href= ' <%=theurl%>& Page=1 ' > Home </a> <%} if (showpage>1) {%><a class= ' f-12-black ' href= ' "<%=theurl%>&page=" <%= showPage-1%> ' > Prev </a>&nbsp;<%} if (showpage<pagecount) {%>&nbsp;<a class= ' F-12-black ' href= ' <%=theurl%>&page=<%= showpage+1%> ' > Next </a>&nbsp;<%}%>& nbsp;<% if (showpage<pagecount) {%><a class= ' f-12-black ' href= ' <%=theurl%>&page=<%= ' PageCount%> ' > Last </a>&nbsp;<%      }%> page: <%=showpage%>/<% =pagecount%> page Total <%=recCount%> records <a class= ' F-12-black ' > go to <select name= ' sel_page ' onchange= ' Javascript:location=this.options[this.selectedindex].value; ' ><%  for (int I=1;i<=pagecount;i++) { %> <option value= ' <%=theurl%>&page=<%=i%> ' <% if (i==showPage) {%> Selected <%}%>><%=i%></option><%}%></select> page </a></td>
</tr>
</tbody>
</form>
<tr>
<td></TBODY></td>
</tr>
</table>
&LT;BR/></td>
</tr>
</table></td>
</tr>
</table></td>
&LT;TD width= "rowspan=" 3 "style=" Background:url (images/rightbg.jpg) repeat-y left ">&nbsp;</td>
</tr>
</table>
<%
Stmt.close ();
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.