1. 程式人生 > >phpcms分頁查詢

phpcms分頁查詢

使用例子:

$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$memberlist = $this->db->listinfo('', 'userid DESC', $page, 15);
$pages = $this->db->pages;
echo count($memberlist,0);
echo json_encode($memberlist);

多條件例子程式碼:

//點數範圍if($point_from) {
if($point_to) {
if($point_from > $point_to

) {
$tmp = $amount_from;
$point_from = $point_to;
$point_to = $tmp;
unset($tmp);
}
$where .= "`point` BETWEEN '$point_from' AND '$point_to' AND ";
} else {
$where .= "`point` > '$point_from' AND ";
}
}

if($keyword) {
if ($type == '1') {
$where .= "`username` LIKE '%$keyword%'";
} elseif($type == '2') {
$where
.= "`userid` = '$keyword'";
} elseif($type == '3') {
$where .= "`email` like '%$keyword%'";
} elseif($type == '4') {
$where .= "`regip` = '$keyword'";
} elseif($type == '5') {
$where .= "`nickname` LIKE '%$keyword%'";
} else {
$where .= "`username` like '%$keyword%'";
}
} else {
$where .= '1';
}

} else {
$where
= '';
}

$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$memberlist = $this->db->listinfo($where, 'userid DESC', $page, 15);
$pages = $this->db->pages;