一、bootstrap分页
1,js内容
var pageitem = 20;//每页显示数
//是否是第一次加载js
var isfirstload = true;
function initPagination(count){
var num_entries = 0;//总数
if(null== count){
num_entries = $("#count").val();
if(null== num_entries){
num_entries = 0;
}else{
totalcount =num_entries;
}
}else{
num_entries =count;
}
if(num_entries==0){
return;
}
var currentpage = $("#currentpage").val();
if(null==currentpage||""==currentpage){
currentpage=0;
}
$("#Pagination").pagination(num_entries,{
num_edge_entries:3,//边缘显示页数
num_display_entries:8,//主体页数
current_page:currentpage,
callback:pageselectCallback,
items_per_page:pageitem,//每页显示条数
prev_text:"上一页",
next_text:"下一页"
});
};
function pageselectCallback(page_index,jq){
if(isfirstload){
isfirstload = false;//第一次加载完了改false
return;
}
window.location.href="/Sendbytime/sendlist?memberid="+memberid+"¤tpage="+page_index+"&pageitem="+pageitem;//查询内容
}
initPagination();
php页面
if(!isset($_GET['currentpage'])||null==$_GET['currentpage']||""==$_GET['currentpage']){
$currentpage=0;//获取当前页
}else{
$currentpage=$_GET['currentpage'];
}
if(!isset($_GET['pageitem'])||null==$_GET['pageitem']){
$pageitem =20;
}else{
$pageitem = $_GET['pageitem'];
}
$begin = $currentpage*5;
$m = M('sendtime');
$where['memberid']=$memberid;
$sql = "selectw.wxname,s.title,s.id,s.sendtime,s.sendt,s.errcode,s.errmsg from ibr_sendtimes,ibr_wxuser w where s.wxid=w.id and s.memberid=$memberidorder by sendtime desc limit $begin,$pageitem";
$sends = $m->query($sql);//分页查询
if(isset($_GET['count'])){
$count = $_GET['count'];//得到总页数
}else{
$sql1= "selectw.wxname from ibr_sendtime s,ibr_wxuser w where s.wxid=w.id and s.memberid=$memberid";
$count = $m->query($sql1);
}
//$count = count($sends);
$this->assign("count",count($count));
$this->assign("currentpage",$currentpage);
$this->assign("memberid",$memberid);
3,html页面重要内容
<linkrel='stylesheet'type='text/css'href="__PUBLICRESOURCEROOT__/css/bootstrap.min.css"/>
<scriptsrc="__PUBLICRESOURCEROOT__/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript"src="__PUBLICRESOURCEROOT__/js/bootstrap.min.js"></script>
//当前页
<inputtype="hidden" id="currentpage"value="{$currentpage}"/>
//总页数
<inputtype="hidden" id="count"value="{$count}"/>
//查询条件
<inputtype="hidden"id="memberid"value="{$memberid}"/>
//分页div
<divclass="t_center"style="text-align:center">
<divid="Pagination"class="pagination"></div>
</div>
二、bootstrap弹出框
Js页面
$(".test").on("click",function(){
$("#settime").modal("show");
});
Html页面
<divclass="modalfade in"id="settime"tabindex="-1"role="dialog"aria-hidden="false"data-type="1">
<divclass="modal-dialog"style="margin-top:75px;width: 360px;">
<divclass="modal-content">
<divclass="modal-header"style="border:0none;line-height: 38px;">
请选择
</div>
<divclass="modal-body"id="weixin-list-content"style="padding: 0;margin: 15px; margin-top:0px;">
内容区
</div>
<divclass="modal-footertext-right"style="padding:10px 20px 10px;">
<buttontype="button"id="subtime" class="btnbtn-success">确定</button>
<buttontype="button"class="btnbtn-default"data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>