PHP实现文章简单分页代码实例
- 技术交流
- 2024-09-25 19:52:02
total_page = 10;$current_page = empty($_GET['page']) ? 1 : $_GET['page'];$previous_page = $current_page - 1;$next_page = $current_page + 1; if ($previous_page == 0) { $previous_page = 1;} if ($next_page > $total_page) { $next_page = $current_page;} echo "<a href='test.php?page=1'> First Page </a>";echo "<a href='test.php?page=$previous_page'> Previous </a>"; for ($i=1; $i < $total_page; $i++) : if ($current_page == $i) { echo "<a href='test.php?page=$i'> $i - Selected </a>"; }else{ echo "<a href='test.php?page=$i'> $i </a>"; } endfor; echo "<a href='test.php?page=$total_page'> Last Page </a>";echo "<a href='test.php?page=$next_page'> Next </a>";
PHP实现文章简单分页代码实例
PHP实现文章简单分页代码实例由讯客互联技术交流栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“PHP实现文章简单分页代码实例”