欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

在原有的基础上更改的分页模式

程序员文章站 2022-06-09 11:35:52
...
我这个系统是一个音频网站,所有的音频数据都是写在一个字段里,如果有几千条的话!不做分页的话打开网站基本是会卡死的。分享下前台和后台代码给大家,希望功能学习
后台代码//分页开始
$rs = M('Vod');
$user = array();
$user['q_islock'] = $_REQUEST['q_islock'];
$selectType = $_REQUEST['q_selectType'];
$wd = urldecode(trim($_REQUEST['wd']));
$user['selectType'] = $selectType;
$user['wd'] = $wd;
$user['p'] = '';

if ($user['q_islock'] == 1) {
$where['islock'] = array('eq', 1);
}
else if ($user['q_islock'] == 2) {
$where['islock'] = array('eq', 0);
}

if (!empty($selectType) && !empty($wd)) {
$where[$selectType] = array('like', '%' . $wd . '%');
}
$ida=$_GET['id'];
$vod_url=$rs->where("vod_id=$ida")->getfield("vod_url");
$count=(substr_count($vod_url,"$")-3)/2;
$limit = C('url_num_admin');
$totalpages = ceil($count / $limit);
$currentpage = (!empty($_GET['p']) ? intval($_GET['p']) : 1);
$currentpage = get_maxpage($currentpage, $totalpages);
$pageurl = U('/read-id-'.$ida, $user, false, false) . '{!page!}' . C('url_html_suffix');
$user['p'] = $currentpage;
$_SESSION['user_jumpurl'] = U('/read-id-'.$ida, $user) . C('url_html_suffix');
$page = '共' . $count . '个 当前:' . $currentpage . '/' . $totalpages . '页 ' . getpage($currentpage, $totalpages, 3, $pageurl, 'pagego(\'' . $pageurl . '\',' . $totalpages . ')');
$user['page'] = $page;
$f['currentpage']=$currentpage;
$sq['vod_id']=$ida;
$vod_playlist=$rs->find($ida);
$this->assign($f);
$this->assign($user);
//分页结束
模板代码块$fj=($currentpage-1)*20




  • {$gxlcmsson.playname}



  • 在原有的基础上更改的分页模式