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} a>
{/foreach}
{else/}
{/if}
{/if}
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]