Home  >  Q&A  >  body text

Small bug in paging function

Hello Teacher Zhu, there is a small bug in your paginated course (about 16 minutes into the video course). The page number jumps to 1, but the actual data still displays the content on page 2. And why? It will not change even if you click it. You have to manually change the p value to 0 in the URL column to jump back to page 1. How to solve it? ?

iUnicorniUnicorn2040 days ago2144

reply all(6)I'll reply

  • --

    --2019-05-29 21:18:04

    $Previous = ($page - 1)<1?1:($page-1); //Prevent the previous page from overflowing


    ##<li> ;

    <a href="?num=<?=$num?>&page=<?php echo $Previous;?>" aria-label="Previous">

    <span aria-hidden="true">«</span>

    </a>

    </li> ;

    Then call this $Previous variable and do not perform calculations in the <a> tag, then there will be no problem.

    reply
    0
  • 999

    grateful

    999 · 2019-10-12 19:40:15
  • iUnicorn

    iUnicorn2019-04-13 19:57:48

    Teacher, why have I changed two browsers and still can’t reply the code to the website? The reply button is not reflected when clicked..., website BUG?

    reply
    0
  • 天蓬老师

    天蓬老师2019-04-13 11:42:02

    This is a second-year course, and the details are difficult to recall. You can post the code and everyone will help you analyze it

    reply
    0
  • --

    The code in the course was calculated twice, resulting in a BUG. if($page<=1){ $page = $page +1; } echo 'Previous page'; //When it is 1, the value of $page will become 2 through the above calculation.

    -- · 2019-05-29 21:29:58
  • Cancelreply