Fork me on GitHub

分页查询

select * from 表名 limit 0,2;;

(页数-1)*要显示的条数,要显示的条数

分页内容:上一页,下一页,首页,尾页,跳转页,总页数,当前页,每页的数量

每页的数量:程序员设置

总条数:select count(*) from表名

总页数:总条数%每页的数量==0?(总条数%每页条数):(总条数%每页条数+1)

首页: 判断当前页是否为第一页,如果是,超连接无效

尾页:判断当前页是否等于总页数,如果是,超链接无效

上一页:是否等于首页?无效:页码-1

下一页:是否等于尾页?无效:页码+1

当前页码:就是用户传递

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<tr>
<td class="line_table" align="center" colspan="11" height="20">
<span class="left_bt2">第${page.curPage }页 &nbsp;&nbsp;共${page.totalPage }页
</span>&nbsp;&nbsp;
<c:choose>
<c:when test="${page.curPage eq 1 }">
<span style="font-size: 12px; color:gray">[首页]</span>
</c:when>
<c:otherwise>
<a href="${#&&curPage=1}">[首页]</a>
</c:otherwise>
</c:choose>

<c:choose>
<c:when test="${page.curPage eq page.totalPage }">
<span style="font-size: 12px; color:gray">[尾页]</span>
</c:when>
<c:otherwise>
<a href="${#&&curPage=${page.totalPage}">[尾页]</a>
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${page.curPage eq 1 }">
<span style="font-size: 12px; color:gray">[上一页]</span>
</c:when>
<c:otherwise>
<a href="${#&&curPage=${page.curPage-1}">[上一页]</a>
</c:otherwise>
</c:choose>

<c:choose>
<c:when test="${page.curPage eq page.totalPage }">
<span style="font-size: 12px; color:gray">[下一页]</span>
</c:when>
<c:otherwise>
<a href="${#&&curPage=${page.curPage+1}&&userid=${requestScope.ordersInfo.userid}">[下一页]</a>
</c:otherwise>
</c:choose>

</td
</tr>
0%