$html.=' '.$this-config["next"].' ';
else
$html.=" a href='javascript:void(0)' onclick='showPage(\"{$this-uri}page=" . ($this-page + 1) . "\")'{$this-config["next"]}/a ";
//$html.=" a href='https://www.04ip.com/post/{$this-uri}page=".($this-page + 1)."'{$this-config["next"]}/a ";
return $html;
}
/*设置尾页*/
private function last() {
$html = "";
if ($this-page == $this-pageNum)
$html.=' '.$this-config["last"].' ';
else
$html.=" a href='javascript:void(0)' onclick='showPage(\"{$this-uri}page=" . ($this-pageNum) . "\")'{$this-config["last"]}/a ";
//$html.=" a href='https://www.04ip.com/post/{$this-uri}page=.(this-pageNum).'{$this-config["last"]}/a ";
return $html;
}
/*设置页面跳转*/
private function goPage() {
return
' input type="text" onkeydown="javascript:if(event.keyCode==13){var page=(this.value' . $this-pageNum . ')?' . $this-pageNum . ':this.value;showPage(\'' . $this-uri . 'page=\'+page+\'\')}" value="' . $this-page . '" style="width:25px"
input type="button" value="https://www.04ip.com/post/GO" onclick="javascript:var page=(this.previousSibling.value' . $this-pageNum . ')?' . $this-pageNum . ':this.previousSibling.value;showPage(\'' . $this-uri . 'page=\'+page+\'\')" ';
}
//页面列表配置选项
function fpage($display = array(0, 1, 2, 3, 4, 5, 6, 7, 8)) {
$html[0] = " 共有b{$this-total}/b{$this-config["header"]} ";
$html[1] = " 每页显示b" . ($this-end() - $this-start() + 1) . "/b条,本页b{$this-start()}-{$this-end()}/b条 ";
$html[2] = " b{$this-page}/{$this-pageNum}/b页 ";
$html[3] = $this-first();
$html[4] = $this-prev();
$html[5] = $this-pageList();
$html[6] = $this-next();
$html[7] = $this-last();
$html[8] = $this-goPage();
$fpage = '';
foreach ($display as $index) {
$fpage.=$html[$index];
}
return $fpage;
}
}
2 数据显示
?php
//链接数据库
//获得具体信息
//分页显示
header("content-type:text/html;charset=utf-8");
$link = mysql_connect('localhost','root','111111');
mysql_select_db('shop', $link);
mysql_query("set names utf8");
$css = eof
style type="text/css"
table {border:1px solid black; width:700px; margin:auto; border-collapse:collapse;}
td {border:1px solid black; }
/style
eof;
echo $css;
echo "
table
trtd序号/tdtd名称/tdtd数量/tdtd价格/tdtd时间/td/tr
";
//1 引入分页类
include "./Pagination.php";
//2. 获得信息总条数
$sql = "select * from sw_goods";
$qry = mysql_query($sql);
$total = mysql_num_rows($qry);
$per= 7;
//3. 实例化分页类对象
$page_obj = new Pagination($total,$per);
//4. 拼装sql语句,获得每页信息
//利用page_obj实现limit的灵活设置
//$page_obj - limit;
$sqla = "select * from sw_goods ".$page_obj-limit;
$qrya = mysql_query($sqla);
//5. 获得页面列表
$pagelist = $page_obj - fpage(array(3,4,5,6,7,8));
$i=1;
while($rsta = mysql_fetch_assoc($qrya)){
echo "tr";
echo "td".$i++."/td";
echo "td".$rsta['goods_name']."/td";
echo "td".$rsta['goods_number']."/td";
echo "td".$rsta['goods_price']."/td";
echo "td".date("Y-m-d H:i:s",$rsta['goods_create_time'])."/td";
echo "/tr";
}
echo "trtd colspan=5".$pagelist."/td/tr";
echo "/table";
3 ajax无刷新分页实现
open(‘get','http://网址/index.php?page=2')
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ""
html
head
title新建网页/title
meta http-equiv="Content-Type" content="text/html; charset=utf-8" /
meta name="description" content="" /
meta name="keywords" content="" /
script type="text/javascript"
推荐阅读
- 乐华艺人都直播带货,乐华签约艺人
- gis栅格平均值,gis栅格转矢量
- 如何把图片变成ppt背景,如何把图片变成ppt背景图
- 苹果录屏如何录直播,苹果怎么录制直播
- 怎么查询mysql字段名 mysql怎么看字段类型
- 怎么删除qq应用小程序,小程序里面的怎么删除应用
- 竞技游戏变身足球运动员,足球变身素材
- 刘涛直播录屏高清的简单介绍
- vb.net长字串换行 vb数据换行