Small bug in paging function
iUnicorn
iUnicorn 2019-04-12 19:15:41
0
6
2200

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? ?

iUnicorn
iUnicorn

知识,成就梦想!

reply all(3)
--

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


##<li&gt ;

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

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

</a>

</li&gt ;

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

  • reply grateful
    999 author 2019-10-12 19:40:15
iUnicorn

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?

Peter-Zhu

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 The code in the course was calculated twice, resulting in a BUG. if($page<=1){ $page = $page +1; } echo '<a href="?p='.$page-1.'">Previous page</a>'; //When it is 1, the value of $page will become 2 through the above calculation.
    -- author 2019-05-29 21:29:58
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template