MySQL paging technology

Source: Internet
Author: User

<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "gb2312" %>
<% @ Page import = "com. jzm. JavaBean. User" %>
<% @ Page import = "com. jzm. JavaBean. conndb" %>
<% @ Page import = "com. jzm. JavaBean. db_user" %>
<%
String Path = request. getcontextpath ();
String basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/";
%>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML>
<Head>
<%!
Int intpagesize = 2; // number of records displayed on each page
Int currpagebegin; // index of the starting record
Int intpagecount; // the total number of pages.
Int intpage; // the page number to be displayed.
String strpage; // user request page number
%>
</Head>
<Body bgcolor = "CFEF">
The following table lists all query users!
<%
Vector <user> vector = NULL;
Db_user dbuser = new db_user (New conndb ());
Vector = dbuser. getallusers ();
// Obtain the page number to be displayed
Strpage = request. getparameter ("page ");
System. Out. Print ("strpage =" + strpage );
If (strpage = NULL)
{
Intpage = 1;
} Else
{
Intpage = integer. parseint (strpage );
If (intpage <1)
Intpage = 1;
}

// Calculate the total number of pages
Intpagecount = (vector. Size () + intPageSize-1)/intpagesize;
// Adjust the page number to be displayed
If (intpage> intpagecount)
Intpage = intpagecount;

// Calculate the index of the Start record on each page
Currpagebegin = intpage * intpagesize-intpagesize;
%>

<Table border = 1 cellspacing = 0 width = 80%>
<Tr>
<TD> User Name </TD>
<TD> password </TD>
<TD> gender </TD>
<TD> email </TD>
<TD> permission </TD>
<TD> Delete this member </TD>
<TD> modify this member </TD>
</Tr>
<%
For (INT I = currpagebegin; I <intpage * intpagesize & I <vector. Size (); I ++)
{
User user = (User) vector. elementat (I );
%>
<Tr bgcolor = "# f0ffff">
<TD> <% Out. Print (user. getname (); %> </TD>
<TD> <% Out. Print (user. GetPassword (); %> </TD>
<TD> <% Out. Print (user. getsex (); %> </TD>
<TD> <% Out. Print (user. getemail (); %> </TD>
<TD> <% Out. Print (user. getpower (); %> </TD>
<TD> <form action = "delete_user.jsp" method = "Post">
<Input type = "hidden" name = "name" value = <% = user. getname () %>
<Input type = "Submit" name = "delete" value = "delete" onclick = "Return confirm ('delete this user ') "> </form> </TD>
<TD> <form action = "modify_user.jsp" method = "Post">
<Input type = "hidden" name = "name" value = <% = user. getname () %>
<Input type = "Submit" name = "Mod" value = "modify"> </form> </TD>
</Tr>
<% }%>
</Table>
<Table align = "center">
<Tr> <TD align = "right"> page <% = intpage %> total <% = intpagecount %>
<%
If (intpage> 1 ){
%>
<A href = "showalluser. jsp? Page = intPage-1 %> "> previous </a>
<%
} Else {
%>
Previous Page
<%}
%>
<% IF (intpage <intpagecount) {%>
<A href = "showalluser. jsp? Page = <% = intpage + 1%> "> next page </a>
<%} Else {%>
Next Page
<% }%>
</TD>
</Tr>
</Table>

<Center>
<H1> <a href = "adduser. jsp"> Add a user </a>
</Center>

</Body>
</Html>

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.