数据库分页程序解读
2014-01-08 13:25
204 查看
下面这段代码,初看上去,会是0,1循环
其实不然,看输出:
at the beginning of the page,iPage is 0
before click link
iPageNo=0
before * 10,iPageNo is 2
at the beginning of the page,iPage is 10
before click link
iPageNo=10
iPageNo就不过1,上来就是2.
启动程序时,这一段的输出:
at the beginning of the page,iPage is 0
i inside the for but before the if 1
i inside the for loop and if condition is true 1
i inside the for but before the if 2
i inside the for but before the if 3
before click link
iPageNo=0
输出:
iEndResultNo 10
iTotalSearchRecords*iEndResultNo 30
cPage 1
if (iPageNo == 0) { iPageNo = 0; } else { System.out.println("before * 10,iPageNo is "+iPageNo); iPageNo = Math.abs((iPageNo - 1) * iShowRows); } System.out.println("at the beginning of the page,iPage is "+iPageNo);
其实不然,看输出:
at the beginning of the page,iPage is 0
before click link
iPageNo=0
before * 10,iPageNo is 2
at the beginning of the page,iPage is 10
before click link
iPageNo=10
iPageNo就不过1,上来就是2.
for (i = ((cPage * iTotalSearchRecords) - (iTotalSearchRecords - 1)); i <= (cPage * iTotalSearchRecords); i++) { System.out.println("i inside the for but before the if "+i); if (i == ((iPageNo / iShowRows) + 1)) { System.out.println("i inside the for loop and if condition is true "+i);
启动程序时,这一段的输出:
at the beginning of the page,iPage is 0
i inside the for but before the if 1
i inside the for loop and if condition is true 1
i inside the for but before the if 2
i inside the for but before the if 3
before click link
iPageNo=0
//// index of pages int i = 0; int cPage = 0; if (iTotalRows != 0) { cPage = ((int) (Math.ceil((double) iEndResultNo / (iTotalSearchRecords * iShowRows)))); System.out.println("iEndResultNo "+iEndResultNo); System.out.println("iTotalSearchRecords*iEndResultNo "+iTotalSearchRecords*iEndResultNo); System.out.println("cPage "+cPage);
输出:
iEndResultNo 10
iTotalSearchRecords*iEndResultNo 30
cPage 1
相关文章推荐
- 基于VB6+ADO+ListView制作的一个数据库分页显示程序(
- 基于VB6+ADO+ListView制作的一个数据库分页显示程序(完整原程序)
- java分页类(程序处理分页,非数据库处理分页)
- asp.net程序优化 尽量减少数据库连接操作
- PHP实现从PostgreSQL数据库检索数据分页显示及根据条件查找数据示例
- 数据库分页查询方法
- 微信小程序官方文档解读:如何才能避开小程序的规则“雷区”
- asp万用分页程序代码
- mySql 数据库分页
- 数据库分页
- cyusb3014的slavefifo程序的解读
- 搜索列表页,用数据库排序分页和like语句,限制TPS
- MVC数据库数据分页显示
- 百万级数据库记录下的Mysql快速分页优化实例
- MFC+ ACCESS 数据库程序移植到客户机出现ERROR CODE 80004003 解决方案
- 解读ASP.NET Portal Starter Kit(1)——数据库篇
- mybatis连接数据库怎么解决数据库列名和程序属性名不一致的问题
- Tomcat数据库连接池 + JavaBean + 分页技术 + JDBC3.0 + 大型数据库
- 思路清晰的ASP分页程序
- ibatis 实现 物理级别的 分页 兼容多种数据库(转载)