thinkphp5 implements the next article and the previous article. Clicking cannot jump to the page number. How to solve it?
雪梦晨、曦
雪梦晨、曦 2018-09-20 14:14:07
0
2
1380

Controller code:

//Next article

$after = Db('shcontent')->where('id','>' ,$id)->order('id asc')->limit('1')->select();

//Previous article

$nex = Db('shcontent')->where('id','<',$id)->order('id desc')->limit('1')->select();

View code:

<!--Next article-->

{if condition="$after"}

{foreach $after as $va}

<a style="float: right;" href="{:url('index/index/shenghuo_content',["id"=>$val["id "]])}">Next article: {$va.title}</a>

{/foreach}

{else/}

< ;a style="float: right;" href="#">Next article: None</a>

{/if}

<!--Previous One article-->

{if condition="$nex"}

{foreach $nex as $va}

<a style="float: right ;" href="{:url('index/index/shenghuo_content',["id"=>$val["id"]])}">Previous article: {$va.title}</ a>

{/foreach}

{else/}

<a style="float: right;" href="#">Previous article: No more</a>

{/if}

<a style="float: right;" href="#">Previous article: No more</ a>

{/if}


雪梦晨、曦
雪梦晨、曦

reply all(2)
Summer

To find an article, you should use find $nex = Db('shcontent')->where('id','<',$id)->order('id desc')-> limit('1')->find();

雪梦晨、曦

Solved, just use ["id"=>$val["id"]+1] or ["id"=>$val["id"]-1]

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template