limit "+currentPage* pageSize +" ,"+pageSize

来源:互联网 发布:基本公共卫生考核软件 编辑:程序博客网 时间:2024/05/22 07:52

 <%  int currentPage=0;
                int pageSize=15;
                if(request.getParameter("currentPage")!=null)
                {
                  currentPage= Integer.parseInt(request.getParameter("currentPage"));
                 
                }
                int totalRecords=0;
                String sql = "select count(*)     FROM   tablename";
                Conn conn=new Conn();
                ResultSet rsc=null,rs=null;
                try{
                  rsc=conn.getRs(sql);

             while (rsc.next()) {
              totalRecords = rsc.getInt(1);
             }
               
              
                              rs= conn.getRs("select *  from tablename  limit "+currentPage* pageSize +" ,"+pageSize);
                           
                while(rs.next()){ %>
                 

   <%} 
             

    int totalPage= (int)Math.ceil((double)totalRecords/pageSize);  %>

 

 

 

共<B><%=totalRecords%></B>个信息,当前第<B><%=currentPage+1%>/<%=totalPage%></B>页。 <%
  
    if(currentPage <totalPage-1){%>
     <a href="huiyuanlist.jsp?currentPage=<%=currentPage+1%>">
    <img src=/images/down.gif border=0> </a>
    <%
   
    }  %>
       <%if(currentPage> 0){%>
         <a href="huiyuanlist.jsp?currentPage=<%=currentPage-1%>">
       <img src=/images/up.gif border=0>  </a>
       <%} %>

原创粉丝点击