我的表里货号有重复的,首先要筛选掉重复的记录第个货号显示一条。
然后分页。
现在问题是筛选做完了,但我做的是先分页,再筛选,结果每页显示的不一样多,
设置80条,有的筛选掉30条,就只能显示50条了。
怎么才能先筛选再分页?
//以下是分页数量函数
function _divide_page($_sql,$_size){
global $_page,$_pagesize,$_pagenum,$_pageabsolute,$_num;
//分页模块
if (isset($_GET['page'])) {$_page = $_GET['page'];
if (empty($_page) || $_page < 0 || !is_numeric($_page)) {$_page = 1;}
else {$_page = intval($_page);}}
else {$_page = 1;}
$_pagesize = $_size;
//首页要得到所有的数据总和
$_num = mysql_num_rows(mysql_query($_sql));
if ($_num == 0) {$_pageabsolute = 1;}
else {$_pageabsolute = ceil($_num / $_pagesize);}
if ($_page > $_pageabsolute) {$_page = $_pageabsolute;}
$_pagenum = ($_page - 1) * $_pagesize;
$_pageabsolute = ceil($_num / $_pagesize);
}
//以下是分页标签函数
function _partition_page(){
global $_page,$_pageabsolute,$_num;
echo '
';
// echo '- 共有'.$_num.'个会员
';
if ($_page == 1) {
echo '- |<
';
echo '- <<
';
} else {
echo '- |<
';
echo '- <<
';
}
if ($_page == $_pageabsolute) {
echo '- >>
';
echo '- >|
';
} else {
echo '- >>
';
echo '- >|
';
}
echo '- '.$_page.'/'.$_pageabsolute.'页
';
echo '
';
}
//以下是页面头部
global $_pagenum,$_pagesize;
_divide_page(
"SELECT * FROM product ",80
);
$result = mysql_query("SELECT * FROM product ORDER BY id DESC LIMIT $_pagenum,$_pagesize");
//下面是HTML
while (!!$_n = mysql_fetch_array($result)) {
if ($_n['num'] != $_o && !empty($_n['img'])) {
?>
- // $_receive = mysql_query("SELECT * FROM img WHERE code='{$_n['img']}' ");
// $_m = mysql_fetch_array($_receive)
?>
">
id=
_partition_page();?>
回复讨论(解决方案)
调用时 _divide_page(
"SELECT * FROM product ",80
);
你的sql指令怎么没有筛选条件?