찾다

 >  Q&A  >  본문

thinkphp5는 다음 글을 구현했는데 이전 글을 클릭하면 페이지 번호로 이동할 수 없습니다. 어떻게 해결하나요?

컨트롤러 코드:

//다음 글

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

//이전 기사

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

코드 보기:

<!--다음 기사-->

{if 조건=" $after"}

{foreach $after as $va}

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

{/foreach}

{else/}

<a style="float: right; " href="#">다음 게시물: 없음</a>

{/if}

<!--이전 게시물-->

{if Condition="$nex"}

{foreach $va}

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

{/foreach}

{else/}

<a style=" float: right;" href="#"> 이전 게시물: 없음</a>

{/if}

<a style="float: right;" href="#">이전 글: 더 이상</a>

雪梦晨、曦雪梦晨、曦2379일 전1438

모든 응답(2)나는 대답할 것이다

  • Summer

    Summer2018-09-20 15:19:10

    기사를 찾으려면 find $nex = Db('shcontent')->where('id','<',$id)->order('id desc')->limit를 사용해야 합니다. ( '1')->찾기();

    회신하다
    0
  • 雪梦晨、曦

    답변 해주셔서 감사합니다

    雪梦晨、曦 · 2018-09-20 15:56:53
  • 雪梦晨、曦

    雪梦晨、曦2018-09-20 15:07:50

    해결되었습니다. ["id"=>$val["id"]+1] 또는 ["id"=>$val["id"]-1]을 사용하세요.

    회신하다
    0
  • 취소회신하다