日期:2014-05-16 浏览次数:20389 次
SELECT DECODE(mod(COUNT(*),100),0,COUNT(*)/100,TRUNC(COUNT(*)/100,0)+1) AS pages FROM XZQH SELECT DECODE(mod(COUNT(*),100),0,COUNT(*)/100,TRUNC(COUNT(*)/100,0)+1)AS pages FROM XZQH
SELECT x.* from (SELECT z.*,rownum numbers from XZQH z where rownum<101) x where x.numbers>90
SELECT x.* from (SELECT z.*,rownum numbers from XZQH z where rownum<101) x where x.numbers>90
select x.* from (select y.*,rownum row_id from (select z.* from admin z )y)x where row_id between 90 and 101
int pageSize=3;//每页显示3条数据 int pageNow=1;//当前显示页数 int pageCount=0;//共有多少页(计算) int rowCount=0;//一共多少条数据(查表) //动态接受PageNow的值从本页面的超链接处得到的值 String pagenow=request.getParameter("pageNow"); if(pagenow!=null){ pageNow=Integer.parseInt(pagenow);//把接受的值传给pageNow }
TestJDBC1 jdbc=new TestJDBC1(); String sql="select count(*)from admin"; ResultSet rs=jdbc.query(sql); try { while(rs.next()){ rowCount=rs.getInt(1);//获得共多少条数据 } } catch (SQLException e) { e.printStackTrace(); }
pageCount = (rowCount + pageSize - 1) / pageSize;
String sql1="select x.* from (select z.*,rownum numbers from admin z where rownum<="+(pageNow*pageSize)+")x where x.numbers>="+((pageNow*pageSize)-pageSize+1)+"";
String sql1 = "select x.* from (select y.*,rownum row_id from (select z.* from admin z )y)x where row_id between "+((pageNow - 1) * pageSize + 1)+" and "+(pageNow * pageSize);
ResultSet rs1=jdbc.query(sql1); try { while(rs1.next()){ out.println("<tr><td>"+rs1.getString(1)+"</td>"); out.println("<td>"+rs1.getString(2)+"</td>"); out.println("<td>"+rs1.getString(3)+"</td></tr>"); } } catch (SQLException e) { e.printStackTrace(); }
if(pageNow!=1){ out.println("<a href=welcome.jsp?pageNow="+(pageNow-1)+">上一页</a>"); } //判断是否还有足够的页数要显示 if((pageCount-pageNow)<4){ for(int i=pageNow;i<=pageNow+(pageCount-pageNow);i++){ out.println("<a href=welcome.jsp?pageNow="+i+">["+i+"]</a>"); } }else{ for(int i=pageNow;i<=pageNow+4;i++){ out.println("<a href=welcome.jsp?pageNow="+i+">["+i+"]</a>"); } } //下一页 if(pageNow!=pageCount){ out.println("<a href=welcome.jsp?pageNow="+(pageNow+1)+">下一页</a>"); }
int linkCount=3; //显示超链接 //首页