建议集合
//分页
$sql2 = "select * from gandong where jianyi <> ''";
$res2 = $db->query($sql2);
$msg_totle = $db->num_rows($res2); //总条数
$page_show = 10; //每页显示数量
$page_totle = ceil($msg_totle / $page_show); //总页数
$page_now = isset($_GET['page']) ? intval($_GET['page']) : 1; //当前页
$page_now = $page_now > $page_totle ? $page_totle : $page_now;
$page_now = $page_now < 1 ? 1 : $page_now;
$page_last = $page_now - 1; //上一页
$page_last = $page_last < 1 ? 1 : $page_last;
$page_next = $page_now + 1; //下一页
$page_next = $page_next > $page_totle ? $page_totle : $page_next;
$page_frist = ($page_now - 1) * $page_show; //本页第一条条数
$sql = "select * from gandong where jianyi <> '' order by id desc limit ".$page_frist.','.$page_show;
$res = $db->query($sql);
$i = 1;
while($row = $db->fetch_array($res)){
$jianyi = $row['jianyi'];
if($i % 2 == 0){
$bg = "background:#F1F1F1;";
}else{
$bg = "";
}
echo "
$jianyi
";
$i++;
}
?>