video php上下切换,TP3.2实现上下篇切换
要實(shí)現(xiàn)上一篇跟下一篇,需要傳取一個(gè)主鍵值,我們拿新聞舉栗子,首先是新聞列表,我點(diǎn)擊列表會(huì)進(jìn)入內(nèi)容頁(yè),所以 我在點(diǎn)新聞列表的時(shí)候:
前端頁(yè)面:
{$v.a_content}閱讀詳細(xì)
這樣就取到主鍵了;然后進(jìn)入內(nèi)容頁(yè)了
內(nèi)容頁(yè)里有上一篇跟下一篇;
控制器:
//新聞內(nèi)
public function index04(){
$this->ff();
$idds = I('get.id');
//上一篇
$shang = M('article')->where("a_id order('a_id desc')->limit('1')->find();//查數(shù)據(jù)
if($shang){// 判斷如果執(zhí)行成功往前面扔
$this->assign('shang',$shang);
}
else{// 否則讓他的標(biāo)題等于暫無(wú)吧
$shang['a_title'] = "暫無(wú)";
$this->assign('shang',$shang);
}
// 下一篇
//同上
$xia = M('article')->where("a_id >$idds and a_keyword=489")->order('a_id asc')->limit('1')->find();
if($xia){
$this->assign('xia',$xia);
}
else{
$xia['a_title'] = "暫無(wú)";
$this->assign('xia',$xia);
}
$this->display('jiu:public/7-6newsview');
}
前端:
上一篇:{$shang.a_title}
下一篇:{$xia.a_title}
總結(jié)
以上是生活随笔為你收集整理的video php上下切换,TP3.2实现上下篇切换的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: errorgetlast php,php
- 下一篇: java async mysql,jav