时间:2021-07-01 10:21:17 帮助过:0人阅读
- <code><!--?php if($countPage --> 1):?>
- <ul style="overflow:hidden;">
- <!--?php if($currentPage --> 1):?><li>">上一页</li><!--?php endif;?-->
- <!--?php if($currentPage -->= 5 && $countPage >= $currentPage):?>
- <li>">1</li>
- <li>...</li>
- <!--?php endif;?-->
- <!--?php
- $count = ($countPage < 5 ? $countPage : '') ? $countPage : 5;
- for($i = 0; $i < $count; $i++):
- $index = 0;
- if($currentPage/5 -->= 1){
- $index = (($currentPage-5)%3 == 0) ? ($currentPage-5)/3 + 1 : floor(($currentPage-5)/3 + 1);
- }
- $number = 3 * $index + $i + 1;
- ?>
- <li class="<?php echo ((@$_GET['p'] == $number) || (empty($_GET['p'])&&$number==1)) ? 'currentPage' : '';?>">
- "><!--?php echo $number;?-->
- </li>
- <!--?php if($number == $countPage){break;} endfor;?-->
- <!--?php if($countPage !== (int)$number):?--><li>...</li><!--?php endif;?-->
- <li>">下一页</li>
- <li>">末页</li>
- </ul>
- <!--?php endif;?-->
- </code>
我只拿到了四条数据,当前页,总页,上一页,下一页;
有没有别的写法 , 我想我这种很低劣吧
- <code><!--?php if($countPage --> 1):?>
- <ul style="overflow:hidden;">
- <!--?php if($currentPage --> 1):?><li>">上一页</li><!--?php endif;?-->
- <!--?php if($currentPage -->= 5 && $countPage >= $currentPage):?>
- <li>">1</li>
- <li>...</li>
- <!--?php endif;?-->
- <!--?php
- $count = ($countPage < 5 ? $countPage : '') ? $countPage : 5;
- for($i = 0; $i < $count; $i++):
- $index = 0;
- if($currentPage/5 -->= 1){
- $index = (($currentPage-5)%3 == 0) ? ($currentPage-5)/3 + 1 : floor(($currentPage-5)/3 + 1);
- }
- $number = 3 * $index + $i + 1;
- ?>
- <li class="<?php echo ((@$_GET['p'] == $number) || (empty($_GET['p'])&&$number==1)) ? 'currentPage' : '';?>">
- "><!--?php echo $number;?-->
- </li>
- <!--?php if($number == $countPage){break;} endfor;?-->
- <!--?php if($countPage !== (int)$number):?--><li>...</li><!--?php endif;?-->
- <li>">下一页</li>
- <li>">末页</li>
- </ul>
- <!--?php endif;?-->
- </code>
我只拿到了四条数据,当前页,总页,上一页,下一页;
有没有别的写法 , 我想我这种很低劣吧
使用Laravel做分页的输出,可以一行代码搞定,很优雅!具体参照它的API