我这个系统是一个音频网站,所有的音频数据都是写在一个字段里,如果有几千条的话!不做分页的话打开网站基本是会卡死的。分享下前台和后台代码给大家,希望功能学习
后台代码//分页开始<br>
$rs = M('Vod');<br>
$user = array();<br>
$user['q_islock'] = $_REQUEST['q_islock'];<br>
$selectType = $_REQUEST['q_selectType'];<br>
$wd = urldecode(trim($_REQUEST['wd']));<br>
$user['selectType'] = $selectType;<br>
$user['wd'] = $wd;<br>
$user['p'] = '';<br>
<br>
if ($user['q_islock'] == 1) {<br>
$where['islock'] = array('eq', 1);<br>
}<br>
else if ($user['q_islock'] == 2) {<br>
$where['islock'] = array('eq', 0);<br>
}<br>
<br>
if (!empty($selectType) && !empty($wd)) {<br>
$where[$selectType] = array('like', '%' . $wd . '%');<br>
}<br>
$ida=$_GET['id'];<br>
$vod_url=$rs->where("vod_id=$ida")->getfield("vod_url");<br>
$count=(substr_count($vod_url,"$")-3)/2;<br>
$limit = C('url_num_admin');<br>
$totalpages = ceil($count / $limit);<br>
$currentpage = (!empty($_GET['p']) ? intval($_GET['p']) : 1);<br>
$currentpage = get_maxpage($currentpage, $totalpages);<br>
$pageurl = U('/read-id-'.$ida, $user, false, false) . '{!page!}' . C('url_html_suffix');<br>
$user['p'] = $currentpage;<br>
$_SESSION['user_jumpurl'] = U('/read-id-'.$ida, $user) . C('url_html_suffix');<br>
$page = '共' . $count . '个 当前:' . $currentpage . '/' . $totalpages . '页 ' . getpage($currentpage, $totalpages, 3, $pageurl, 'pagego(\'' . $pageurl . '\',' . $totalpages . ')');<br>
$user['page'] = $page;<br>
$f['currentpage']=$currentpage;<br>
$sq['vod_id']=$ida;<br>
$vod_playlist=$rs->find($ida);<br>
$this->assign($f);<br>
$this->assign($user);<br>
//分页结束
模板代码块<php>$fj=($currentpage-1)*20</php><br>
<volist> <br>
<if><br>
<fflist><br>
<br>
<li>
<time>更新时间:{$vod_addtime|date='Y-m-d H:i:s',###}</time><i></i><a>{$gxlcmsson.playname}</a>
</li>
<br>
</fflist><br>
<br>
</if> </volist>