PHP分页原理

1.核心是利用mysql数据库中的limit来进行分页

语句:select * from tbArticle where status="0003" order by sn DESC limit offset, 100;

offSet为开始值,100为每页的限制值

2.上一页和下一页,利用js中页面的window.location.href 来进行页面的跳转

$(".prePage").click(function(){
var articleStatus = getArticleStatus();
var pageNum = getPageNum() - 1;

if (pageNum < 1) {
window.location.href="./getArticleList.html?articleStatus=" + articleStatus + "?pageNum=1";
}else{
window.location.href="./getArticleList.html?articleStatus=" + articleStatus +"?pageNum="+pageNum;
}
})

$(".nextPage").click(function(){
var articleStatus = getArticleStatus();
var pageNum = parseInt(getPageNum()) + 1;
window.location.href="./getArticleList.html?articleStatus=" + articleStatus +"?pageNum="+pageNum;
})
});

 

posted @ 2016-10-10 17:29  满月青灰  阅读(227)  评论(0编辑  收藏  举报