我這個系統是一個音訊網站,所有的音訊資料都是寫在一個欄位裡,如果有幾千條的話!不做分頁的話打開網站基本上是會卡死的。分享下前台與後台程式碼給大家,希望功能學習
後台程式碼//分頁開始<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)。
$user['p'] = $currentpage;<br>
$_SESSION['user_jumpurl'] = U('/read-id-'.$ida, $user). C('url_html_suffix');<br>
$page='共'. $計數。 . $totalpages . ')');<br>
$user['page'] = $page;<br>
$f['currentpage']=$currentpage;<br>
$sq['vod_id']=$ida;<br>
$vod_playlist=$rs->find($ida);<br>
$this->分配($f);<br>
$this->分配($user);<br>
//分頁結束<br>模板程式碼區塊
<volist name="gxlcms_playlist" id="gxlcms"> <br>
<if eq ts><br>
<fflist name="gxlcms['son']" id="gxlcmsson" order="asc" offset="$fj" length="20"><br>
<br> <li>
<time>更新時間:{$vod_addtime|date='Y-m-d H:i:s',###}</time><i> </i><a href="%7B%24gxlcmsson.playurl%7D">{$gxlcmsson.playname}</a>
</li>
<br>
</fflist><br>
<br>
如果> </if></volist>