zoukankan      html  css  js  c++  java
  • 上一章下一章

    好久不写代码了,今天突然用到了上一章下一章(一个小说网站,在这里面我用的是Thinkphp框架),就总结了下,上一章下一章,要用到书的id(bookid)和章节的id(chapterid)具体如下:

    function checkChapter($bookid,$chaper){//书id,和章节id

    $chapters = M("chapters");  

    $chapterNex = $chapters->where("acc_bookid=$bookid and acc_chapterid > $chaper")->find();//下一章  

    $chapterPre = $chapters->where("acc_bookid=$bookid and acc_chapterid < $chaper")->order("acc_chapterid desc")->find();//上一章

     $str_chapter = '';

     if(!empty($chapterPre) && empty($chapterNex)){   

    $str_chapter .= '<a href="'.U('Reader/index',array('bookid'=>$bookid,'chapterid'=>$chapterPre['acc_chapterid'])).'">上一章</a>    <a href="'.U('View/index',array('bookid'=>$bookid)).'">返回目录</a>';  }  

    if(empty($chapterPre) && !empty($chapterNex)){

      $str_chapter .= '<a href="'.U('View/index',array('bookid'=>$bookid)).'">返回目录</a>      <a href="'.U('Reader/index',array('bookid'=>$bookid,'chapterid'=>$chapterNex['acc_chapterid'])).'">下一章</a>';  }  

    if(!empty($chapterPre) && !empty($chapterNex)){   

    $str_chapter .= '<a href="'.U('Reader/index',array('bookid'=>$bookid,'chapterid'=>$chapterPre['acc_chapterid'])).'">上一章</a>      <a href="'.U('View/index',array('bookid'=>$bookid)).'">返回目录</a>      <a href="'.U('Reader/index',array('bookid'=>$bookid,'chapterid'=>$chapterNex['acc_chapterid'])).'">下一章</a>';  }  

    return $str_chapter;

    }

  • 相关阅读:
    微信小程序-----校园头条详细开发之注册登录
    微信小程序-----校园头条详细开发之首页
    day 99天
    day 98天
    day 97 VUE第一天
    day 96
    day 95天
    day 94 RestFramework序列化组件与视图view
    day 93 Restframwork
    day 92
  • 原文地址:https://www.cnblogs.com/yuexin/p/3205528.html
Copyright © 2011-2022 走看看