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
1301

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:

{if condition="$after"}

{foreach $after as $va}

$val["id "]])}">Next article: {$va.title}

{/foreach}

{else/}

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

{/if}

{if condition="$nex"}

{foreach $nex as $va}

$val["id"]])}">Previous article: {$va.title}

{/foreach}

{else/}

Previous article: No more

{/if}

Previous article: No more

{/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
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!